.NET 4.7 Desktop Form combox coloring within datagridview
-
I can't find the setting(s) to change the color of a combobox within a datagridview. I tried this code below. I get a dark line around the datagridview cell and a white background. I see the colors I set below when I view the list within the combobox. combo.DisplayStyle = DataGridViewComboBoxDisplayStyle.ComboBox; combo.CellTemplate.Style.BackColor = Color.LightSalmon; combo.CellTemplate.Style.ForeColor = Color.Black; combo.CellTemplate.Style.SelectionBackColor = Color.LightSalmon; combo.CellTemplate.Style.SelectionForeColor = Color.Black;
-
I can't find the setting(s) to change the color of a combobox within a datagridview. I tried this code below. I get a dark line around the datagridview cell and a white background. I see the colors I set below when I view the list within the combobox. combo.DisplayStyle = DataGridViewComboBoxDisplayStyle.ComboBox; combo.CellTemplate.Style.BackColor = Color.LightSalmon; combo.CellTemplate.Style.ForeColor = Color.Black; combo.CellTemplate.Style.SelectionBackColor = Color.LightSalmon; combo.CellTemplate.Style.SelectionForeColor = Color.Black;
Microsoft have knobbled many features of quite a few controls (e.g. ProgressBar - we all prefer green! MonthCalendar - change the font to make it big enough to see - No!) and often the only thing you can do is to disable visual styles. That can be a problem though as some controls require visual styles to be on (e.g the Tile mode of the ListView). However with the DataGridView the colour works in the way you desire when the FlatStyle of the ComboBoxColumn is set to either FlatStyle.Flat or FlatStyle.Popup. I guess they missed that.
-
Microsoft have knobbled many features of quite a few controls (e.g. ProgressBar - we all prefer green! MonthCalendar - change the font to make it big enough to see - No!) and often the only thing you can do is to disable visual styles. That can be a problem though as some controls require visual styles to be on (e.g the Tile mode of the ListView). However with the DataGridView the colour works in the way you desire when the FlatStyle of the ComboBoxColumn is set to either FlatStyle.Flat or FlatStyle.Popup. I guess they missed that.