Hello Infragistics,
I have a grid with a couple bound columns and one column that is not bound but has a Style property of a button so when a new row is added that column shows a button. Everything seems to work great so far but my problem is trying to change anything to the button as far as the appearance.
When i add rows to the grid, I check the stated of some code and depending on the state is what i color the button. I need to be able to change the background color and I currently have not found a way to do this.
Hi,
Okay, so you are probably using the InitializeRow event and setting the Appearance on the cell. But that won't have any effect on the button, only on non-button cells. You need to use the ButtonAppearance property on the cell, instead.
Also, by default, the buttons in the grid are drawn using OS Themes, which means you cannot change the colors. Themed drawing is all or nothing. So if you want to change the colors of the buttons, you have to turn off themes.
You can turn off themes on the entire grid with the UseOsThemes property.
You could turn off themes on the entire application using AppStylist.
Or, you could turn off themes just on the buttons by setting the ThemedElementAlpha on the ButtonAppearance to Transparent.
Here's some quick sample code to point you in the right direction.
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { UltraGridLayout layout = e.Layout; UltraGridBand band = layout.Bands[0]; UltraGridOverride ov = layout.Override; band.Columns["String 1"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Button; if (false == layout.Appearances.Exists("Yellow")) { Infragistics.Win.Appearance yellowAppearance = layout.Appearances.Add("Yellow"); yellowAppearance.ThemedElementAlpha = Alpha.Transparent; yellowAppearance.BackColor = Color.Yellow; yellowAppearance.ForeColor = Color.Black; } if (false == layout.Appearances.Exists("Green")) { Infragistics.Win.Appearance greenAppearance = layout.Appearances.Add("Green"); greenAppearance.ThemedElementAlpha = Alpha.Transparent; greenAppearance.BackColor = Color.Green; greenAppearance.ForeColor = Color.Black; } } private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e) { int i = (int)e.Row.Cells["Int32 1"].Value; if (i < 0) e.Row.Cells["String 1"].Appearance = e.Row.Band.Layout.Appearances["Yellow"]; else e.Row.Cells["String 1"].Appearance = e.Row.Band.Layout.Appearances["Green"]; }
Hi Mike,
Thank you for the quick response. I would potentially need to change the color on each row.
Thanks!
Do you want the buttons in every row to the same color? Or are you trying to set a different color on each row (potentially)?