I have a wingrid control, I set the style for one of the column as color.
col.Style = UltraWinGrid.ColumnStyle.Color
I want the text of the cell shown as [#26A65B], not as [38, 166, 91]. What shall I do?
Thank you.
Hi Liu,
Thank you for posting to Infragistics Community!
I have been looking into your question and found this forum thread where the same question is discussed, only about the UltraColorPicker control, which is the underlying editor when the Style is set to “ColumnStyle.Color” for a column in the UltraGrid.
The suggested approach there involves defining a class implementing the IEditorDataFilter interface, which allows to modify the values assigned to the editor, and for example display the HEX value instead of the RGB one. More about Using the IEditorDataFilter Interface with the UltraGrid can be read in this topic of our documentation.
For your convenience, below I am attaching a sample with an UltraDataGrid and the implemented DataFilter assigned to its color column:
this.ultraGrid1.DisplayLayout.Bands[0].Columns[0].Editor.DataFilter = new MyDataFilter();
Please, test it on your side and if you require any further assistance on the matter, please, let me know.
Best regards, Bozhidara Pachilova Associate Software Developer
Thank you very much for you help. For a unbound column. I found the code runs well. However, I found that with a pre-bound column, the datatype has already been set as a string column. This way, after select value from a colorpicier, the very is still shown as rgb value. I want set the datatype for the column. met the exception:
DataType can only be set for an unbound column.
What shall I do for this column? Thank you.
As pert he UltraGridColumn’s API page for the DataType Property here, the latter is read-only for bound columns.
Therefore, this line is expected to throw the error and additionally, I believe it is redundant.
Consequently, from your description I understand that the color data value in your data is a string, is that right?
What I can suggest in this case is to also handle the “EditorToOwner” and “OwnerToEditor” cases with the same code as the "EditorToDisplay" case in the previously referenced sample.
To demonstrate this, I modified the sample so that the “Col0” column, which represents color also is a string data type in the data source.
With the DataFilter modified in this way, only the hex color is displayed after editing as well:
In conclusion, please, check out this modification of the suggested approach and let me know if it helps.
Thank you very much. The code works fines for me.
I am glad that you find the suggestions helpful. Thank you for using Infragistics components!
Best regards, Bozhidara Pachilova