Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2306
Column with style FormattedText
posted

 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

 

Parents
No Data
Reply
  • 469350
    Offline posted

    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. 

Children