Chnging Color in single cell or row.

Hi.
How can I change background color in the GridListControl for the single cell or row ?

gridListControl1.Grid[rowindex, colindex].BackColor = Color.FromArgb(((System.Byte)(255)), ((System.Byte)(0)), ((System.Byte)(0))); - doesn't work

5 Replies

JJ Jisha Joy Syncfusion Team June 2, 2010 04:54 AM UTC

Hi Michael,

You need to handle Grid.QueryCellInfo event of GridListControl to apply styles to the grid cells.

this.gridListControl1.Grid.QueryCellInfo += new Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventHandler(Grid_QueryCellInfo);

void Grid_QueryCellInfo(object sender, Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs e)
{
if (e.RowIndex == 2 && e.ColIndex == 2)
e.Style.BackColor = Color.PaleGoldenrod;
}


Please let me know if this helps.

Regards,
Jisha


MI Michael June 3, 2010 10:08 AM UTC

Thank you Jisha.
It's works perfect.


JJ Jisha Joy Syncfusion Team June 4, 2010 03:46 AM UTC


Hi Michael,

Thank you for your update.

Regards,
Jisha


AU Alexey Usanov August 12, 2010 10:11 AM UTC

Dear Jisha,
is it possible to access GridControl in GridDataBoundGrid? There is no such propery as Grid here.


JJ Jisha Joy Syncfusion Team August 13, 2010 09:09 AM UTC

Hi Alexy,

You could achieve the desired behavior by handling the Model.QueryCellInfo event.

this.gridDataBoundGrid.Model.QueryCellInfo += new Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventHandler(Grid_QueryCellInfo);

void Grid_QueryCellInfo(object sender, Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs e)
{
if (e.RowIndex == 2 && e.ColIndex == 2)
e.Style.BackColor = Color.PaleGoldenrod;
}

Regards,
Jisha

Loader.
Up arrow icon