We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Displaying different colors for items in a combobox inside a grid.

Hi, I am a Newbie to Syncfusion components. Can somebody tell me how to accomplish the following two things. 1. Display Images/colors in a grid column based on the content of this Row/Column coordinate. In other words, the Cell contains a foreign key to an Image table, or a Colors table with color code pair in hexa decimal format. Now, I want to paint each cell with the information (specific to that cell) like displaying a picture or some sample text like "Sample" and display it in specific BG and FG colors. I think I can create these objects (image or Colors) at runtime by walking the datasource table. But I don''t know where would I put the code to populate the cells. Which event would I use? 2. If I have a combobox in one of the columns of this grid (or even a standalone combobox), is there a way to display the dropdown items in various colors too, based on the datasource column contents? Any help is highly appreciated. Babu.

3 Replies

AD Administrator Syncfusion Team February 12, 2004 04:04 PM

1) If these cells are displayonly, then you can handle the DrawCell event. There you can get the value from the datasource in the e.Style.CellValue object. And then you can draw whatever you want based on the value. If youwant these cells to be editable, then you probably would be better off deriving a cell control to manage this work. 2) There is no built in support for this behavior in a grid cell with a combobox. But if you use a cell with a GridListControl dropdown, and a cell that drops down another grid, then you can do whatever you want as far as specifying colors or fonts. It is a little more to customize a dropdown gridlistcontrol, so you might want to use a drop down GridControl. You can see a sample of such a cell in Syncfusion\Essential Suite\Grid\Samples\In Depth\DropdownGrid. In a standard combobox, you would have to handle DrawItem (drawing things yourself) to manage this behavior.


BM Babu Mannaravalappil February 12, 2004 08:26 PM

Thanks a lot. I will try your suggestions. Babu. >Hi, >I am a Newbie to Syncfusion components. Can somebody tell me how to accomplish the following two things. >1. Display Images/colors in a grid column based on the content of this Row/Column coordinate. In other words, the Cell contains a foreign key to an Image table, or a Colors table with color code pair in hexa decimal format. Now, I want to paint each cell with the information (specific to that cell) like displaying a picture or some sample text like "Sample" and display it in specific BG and FG colors. I think I can create these objects (image or Colors) at runtime by walking the datasource table. But I don''t know where would I put the code to populate the cells. Which event would I use? >2. If I have a combobox in one of the columns of this grid (or even a standalone combobox), is there a way to display the dropdown items in various colors too, based on the datasource column contents? >Any help is highly appreciated. >Babu.


BM Babu Mannaravalappil February 15, 2004 11:12 AM

OK. I tried the CurrentCellChanged event and you are right. Though it fires twice, it does fire every time I make changes to the cell even if I am still in the same cell. But the CurrentCellChanging event does not fire if you try the change the value again in the same cell. FYI. Babu.

Loader.
Live Chat Icon For mobile
Up arrow icon