RC
Rajadurai C
Syncfusion Team
February 9, 2009 05:36 AM UTC
Hi Lan,
Thanks for your interest in Syncfusion products.
The cell specific properties like BackColor (other than CellValue or Text) cannot be set using an indexer like this.gridGroupingControl1.TableModel[4,3].BackColor=Color.Red. In ggc, the only data storage is the bound datasource. That only holds a single value. It does not hold TextColor, or Backcolor, or any of the other many cell specific properties.
Inorder to set cellspecific properties in ggc, you have to handle QueryCellStyleInfo event handler. However, you can control this event to be fired through a button click event based on your own settings.
Please refer to the following code snippet in which the code within the QueryCellStyleInfo event get executed only when the button click event occurs.
bool b = false;
//button click event
private void button1_Click(object sender, EventArgs e)
{
b = true;
this.gridGroupingControl1.TableControl.Refresh();
}
//QueryCellStyleInfo event
void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if(b)
{
if (e.TableCellIdentity.ColIndex == 5 && e.TableCellIdentity.RowIndex > 3)
{
if (int.Parse(e.Style.Text) > 75)
e.Style.BackColor = Color.Blue;
else
e.Style.BackColor = Color.Pink;
}
}
}
Regards,
Rajadurai