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. Image for the cookie policy date

changing cell color at startup

Hi, I''d like to initialize the color of a set of cells based on their grouping grid coordinates, but I don''t want to affect the color of the group header rows/columns in the process. Here''s what I''d like to say in my TableControlPrepareViewStyleInfo handler: int row = e.Inner.RowIndex; int col = e.Inner.ColIndex; if ((col >= 4 && row <= 5) && "cell is not some sort of header") { e.Inner.Style.BackColor = Color.LightGoldenrodYellow; } Any ideas on how I can accomplish this would be greatly appreciated. Thank you, Clario

2 Replies

Administrator August 18, 2004 10:46 AM UTC

Hi Clario, Try code like this instead: private void groupingGrid1_TableControlPrepareViewStyleInfo(object sender, GridTableControlPrepareViewStyleInfoEventArgs e) { GridTableCellStyleInfo style = (GridTableCellStyleInfo) e.Inner.Style; if (style.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell || style.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell) { Record r = style.TableCellIdentity.DisplayElement.ParentRecord; int recordIndex = r.ParentTable.Records.IndexOf(r); GridColumnDescriptor column = style.TableCellIdentity.Column; if (column.TableDescriptor.Columns.IndexOf(column) == 4) e.Inner.Style.BackColor = Color.Red; } } Not sure about this one but check out also the GridEngine.AllowCacheStyles property which we added for 2.1. Then you could do the coloring also in QueryCellStyleInfo. Then option forces GridRecordRow and GridCaptionRow elements to keep a cache with style information for individual cells and reduce the number of QueryCellStyleInfo calls being raised for this cells. Stefan

CM Clario Menezes August 19, 2004 12:47 PM UTC

Thanks a lot, Stefan! The code you sent worked very well. - Clario
Loader.
Live Chat Icon For mobile
Up arrow icon