A few questions about conditionally setting cell properties:
1. In the below code sample, the readonly property is being properly set in the desired columns and rows. The backcolor property, however, is being improperly set to red in what appear to be random rows. After the initial load of the grid, clicking on random rows will produce random red cells (although all in the proper column).
2. Why would this exact same code produce no result in the PrepareViewStyleInfo event?
3. What''s the simplest way change the textcolor of a cell once it''s been edited?
Please note that all columns are initialized to ReadOnly = true.
private void gridLedger_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
if(data condition is met...)
this.gridLedger.Model.IgnoreReadOnly = true;
e.Style.ReadOnly = false;
e.Style.BackColor = System.Drawing.Color.Red;
this.gridLedger.Model.IgnoreReadOnly = false;
ADAdministrator Syncfusion Team November 5, 2004 06:10 PM UTC
Try not using IgnoreReadOnly to see if this will avoid the problem. It should not be needed in QueryCellInfo.
Here is a KB on why ReadONly needs to be set in QueryCellInfo and not PrepareViewStyleInfo.
To set the color while you are editing, try handling PrepareViewStyleInfo. If the e.ColIndex and e.RowIndex point to the current cell (grid.CurrentCell.RowIndex and grid.CurrentCell.COlIndex) and grid.CurrentCell.IsEditing, then set teh color.