From a earlier post, I read that the Appearance set in code take precedence over the AppStylist setting. I have not spent time working with AppStylist but as I understand if affects the Appearance objects for the cells
In my grid, some cells need to have certain display attributes different relative to other cells. For example, some cell need bold fonts but the other attributes should be what AppStylist decides. In other cases, I want different foreground color for text but other attributes as set by AppStylist.That way when the AppStylist is used, it would affect the default look of the cell while the code would apply the special attributes to those cell relative to that default look.
Possible?
Thanks!
Sweet, this has saved me the hastle of iterating through the cells one by one on each row to determine if they are in an error condition.
Thanks Mike but I had to be a little more dynamic.
Private Sub grdListData_InitializeRow(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeRowEventArgs) Handles grdListData.InitializeRow For each Cell as Infragistics.Win.UltraWinGrid.UltraGridCell in e.Row.Cells If e.Row.Cells.Exists(cell.Column.Key & "_Color") then If not e.Row.Cells(cell.Column.Key & "_Color").Value is system.DBNull.Value then Cell.Appearance.ForeColor = color.FromKnownColor(CType(e.Row.Cells(cell.Column.Key & "_Color").Value, KnownColor)) End If End If Next End Sub
There's nothing to it:
private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e) { UltraGrid grid = (UltraGrid)sender; int x = (int)e.Row.Cells["Int32 1"].Value; switch (x) { case 0: e.Row.Cells["String 1"].Appearance = grid.DisplayLayout.Appearances["Red"]; break; case 1: e.Row.Cells["String 1"].Appearance = grid.DisplayLayout.Appearances["Yellow"]; break; case 2: e.Row.Cells["String 1"].Appearance = grid.DisplayLayout.Appearances["Blue"]; break; } }
I am also looking at setting different call appearence properties based on the value in another cell. My issue seems to be getting the proper object.
My plan was to loop through the cells in the InitializeRow event, but I have not been able to get the proper syntax.
Can you provide an example of setting appearence properties of a cell based on another cell?
The appearance of a cell is resolved through a very robust process. The cell looks at it's own appearance, then the CellAppearance of the column, then the CellAppearance of the Row, then it takes into account the selected or active state, and then when you add AppStylist into it, it becomes quite mind-boggling.
But what you are describing here is very easy. The Appearance resolution only resolves properties that have actually been set. So if you set a cell.Appearance.ForeColor, then only the forecolor is resolved. If the BackColor is not set, it will get resolved by some other appearances further up the chain.