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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

comboBox, color of dropdown vs color of the cell

Thread ID:

Created:

Updated:

Platform:

Replies:

71767 Feb 12,2008 03:01 PM UTC Feb 20,2009 08:24 PM UTC WinForms 5
loading
Tags: GridControl
Paul P
Asked On February 12, 2008 03:01 PM UTC

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?


SubhaSheela R [Syncfusion]
Replied On 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



Paul P
Replied On 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?




SubhaSheela R [Syncfusion]
Replied On 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



Sameer Khan
Replied On 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





Sameer Khan
Replied On 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







CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;