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

comboBox, color of dropdown vs color of the cell

When I set .CellType to "ComboBox" and then set .BackColor to something, it only affects the color of the dropdown when I select it. After I select it, it goes back to the grid's color. How can I change the color of the cell the dropdown is "in". Does this make sense?


5 Replies

SR SubhaSheela R Syncfusion Team February 13, 2008 08:56 AM UTC


Hi Paul,

Thank you for using Syncfusion products.

The below sample shows how to set back color to ComboBox cell as well as its DropDown part. You can set the back color of the ComboBoxCell by using BackColor property of GridControl. You can handle CurrentCellShowingDropDown event of the GridControl to set back color to the DropDown part by using BackColor property of ListBoxPart.
Below is the code snippet:

gridControl1[4, 2].BackColor = Color.Pink;
void gridControl1_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs arg)
{
GridCurrentCell cc = this.gridControl1.CurrentCell;
GridComboBoxCellRenderer cr = cc.Renderer as GridComboBoxCellRenderer;
cr.ListBoxPart.BackColor = Color.Blue;
cr.ListBoxPart.ForeColor = Color.Cyan;
}


Please refer to the sample available in the link below and let me know if it helps:

http://websamples.syncfusion.com/samples/Grid.Windows/F71767/main.htm

Regards,
Subhasheela R




PP Paul P February 14, 2008 01:38 PM UTC

It doesn't seem to work the same way for me (not your example, but my code).

In the constructor of the form, I do

this.grid1[1,2.CellType = "ComboBox";
this.grid1[1,2].ChoiceList = myList;
this.grid1[1,2].BackColor = Color.Gray;

This sets the background of the DROPDOWN PART. I would think that it should set the background of the cell part, but it does not for some reason. I am using version 5.something. Does it work differently in the contructor for some reason?





SR SubhaSheela R Syncfusion Team February 15, 2008 04:59 AM UTC

Hi Paul,

Thank you for using Syncfusion products.

I am not able to reproduce the issue of ComboBox back color is not setting in Grid Control. The below sample shows the back color setting for Grid's ComboBox cell. Could you please modify the sample to reproduce the issue, so that I could provide you the exact solution. Or please send us your sample with issue, we will analyze it and provide you the details. Also, send us your correct version details. Below is the code snippet:

public Form1()
{
InitializeComponent();
StringCollection items = new StringCollection();
items.Add("Apple");
items.Add("Grapes");
items.Add("Banana");
items.Add("Mango");
items.Add("Cherry");
gridControl1[4, 2].CellType = "ComboBox";
gridControl1[4, 2].ChoiceList = items;
gridControl1[4, 2].BackColor = Color.Pink;
}


Please refer the sample available in the link below and let me know if it helps:


http://websamples.syncfusion.com//samples/Grid.Windows/I71767FollowUp/main.htm


Regards,
Subhasheela R




SK Sameer Khan February 20, 2009 08:05 PM UTC

How would you do it if the renderer was of type: GridDropDownStandardValuesCellRenderer

Which is what I see when my backing store is an enum.

>
Hi Paul,

Thank you for using Syncfusion products.

The below sample shows how to set back color to ComboBox cell as well as its DropDown part. You can set the back color of the ComboBoxCell by using BackColor property of GridControl. You can handle CurrentCellShowingDropDown event of the GridControl to set back color to the DropDown part by using BackColor property of ListBoxPart.
Below is the code snippet:

gridControl1[4, 2].BackColor = Color.Pink;
void gridControl1_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs arg)
{
GridCurrentCell cc = this.gridControl1.CurrentCell;
GridComboBoxCellRenderer cr = cc.Renderer as GridComboBoxCellRenderer;
cr.ListBoxPart.BackColor = Color.Blue;
cr.ListBoxPart.ForeColor = Color.Cyan;
}


Please refer to the sample available in the link below and let me know if it helps:

http://websamples.syncfusion.com/samples/Grid.Windows/F71767/main.htm

Regards,
Subhasheela R






SK Sameer Khan February 20, 2009 08:24 PM UTC

ListControlPart would do it .. I must be going blind!

>How would you do it if the renderer was of type: GridDropDownStandardValuesCellRenderer

Which is what I see when my backing store is an enum.

>
Hi Paul,

Thank you for using Syncfusion products.

The below sample shows how to set back color to ComboBox cell as well as its DropDown part. You can set the back color of the ComboBoxCell by using BackColor property of GridControl. You can handle CurrentCellShowingDropDown event of the GridControl to set back color to the DropDown part by using BackColor property of ListBoxPart.
Below is the code snippet:

gridControl1[4, 2].BackColor = Color.Pink;
void gridControl1_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs arg)
{
GridCurrentCell cc = this.gridControl1.CurrentCell;
GridComboBoxCellRenderer cr = cc.Renderer as GridComboBoxCellRenderer;
cr.ListBoxPart.BackColor = Color.Blue;
cr.ListBoxPart.ForeColor = Color.Cyan;
}


Please refer to the sample available in the link below and let me know if it helps:

http://websamples.syncfusion.com/samples/Grid.Windows/F71767/main.htm

Regards,
Subhasheela R







Loader.
Live Chat Icon For mobile
Up arrow icon