Hello,
I'd like to disable my UltraGrid but not change the appearance of the grid itself. For example, when you set the Enabled property to false, both the background color of the grid and the text changes to gray. I've tried using the DisplayLayout.Override.RowAppearance.BackColorDisabled property and setting to transparent or even setting it to DisplayLayout.Override.RowSelectorAppearance.BackColor with no luck. Any ideas?
DisplayLayout.Override.RowAppearance.BackColorDisabled = Color.Transparent;
DisplayLayout.Override.RowAppearance.BackColorDisabled = DisplayLayout.Override.RowSelectorAppearance.BackColor;
The code you have here doesn't work becuase you don't want the BackColor to be Transparent, and unless you explcitly SET the BackColor, it will not contain the default or resolved colors that the grid uses.
However, if you set the BackColorDisable to an actual color, it should work. So you will either need to hard-code the colors:
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { var layout = e.Layout; var ov = layout.Override; ov.RowAppearance.BackColorDisabled = Color.White; layout.Appearance.BackColorDisabled = SystemColors.Control; layout.Appearance.ForeColorDisabled = Color.Black; }
Or you could try to resolve the actual colors being used by the grid. This is not trivial, and you would need resolve each color separately. But just as an example, here how you would resolve the colors for the layout:
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { var layout = e.Layout; var ov = layout.Override; AppearanceData appData = new AppearanceData(); AppearancePropFlags flags = AppearancePropFlags.BackColor | AppearancePropFlags.ForeColor; layout.ResolveLayoutAppearance(ref appData, ref flags, true); layout.Appearance.BackColorDisabled = appData.BackColor; layout.Appearance.ForeColorDisabled = appData.ForeColor; }
The rows would be more complicated, since there is no way to resolve the colors for all of the rows, only a single row. So if your rows are all the same color, you could just resolve the color of one row and use that. Otherwise, you would have to loop through every row, and possibly every cell and set it's BackColorDisabled and ForeColorDisabled to BackColor and ForeColor respectively. If you are setting these in code, this could easily be done - just set both properties whenever you set one. If you are doing it using AppStylist, then it would be a good idea to set both properties in AppStylist together.