Hello!
i have a DataTable called dtTables that has a single column=NAME with datatype string and maxlengh=5. I have set the datasource of the grid.DataSource = dtTables;
The style of the column on the grid is set as FormattedText.
If i modify the cell Value in <span style=\"background-color:Yellow;\">hello</span> i see that it is formatted but when i click on another cell i get an error because the grid is going to write that value(which has a a lengh > 5) on the datarow.
How can i avoid that the grid write that value on the datarow?
thank you
There are a couple of way to do this. They are both essentially the same thing:
1) Use a DataFilter. This would allow you to intercept the value as it is transferred from the Owner (think of this as the data source) to the Editor (think of this as the cell) and vice versa. So in the OwnerToEditor transition, you take the raw text and add in the formatting and in the EditorToOwnerconversion, youwould strip out the formatting.
2) Hide the "real" column in the grid and add an unbound column. Us the InitializeRow event to get the value in the "real" bound column and set the value of the unbound column to a formatted text string. Then reverse this process, stripping out the formatting, in the AfterCellUpdate event.
Out of curiosity, what kind of formatted are you doing on a 5-character string? If you just want to change the BackColor, it would probably be a lot easier to just use the Appearance on the cell.
Hi Mike,
It is just an example. In production i dont have strings with MaxLength=5 but strings with MaxLength=number.
The problem is that i need to format part of the string and not the entire string that i see on the cell. I'll use the second method you describe and also i'll use Regular expressions. This is want i want to achieve http://forums.infragistics.com/forums/p/13617/50313.aspx#50313
Any good example for DataFilters?