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
close icon

changing BackColor of particulars cells in a GridDataBoundGrid

Hi,
I've a GridDataBoundGrid with a datable for datasource.

I want to change the backColor and the borders of particulars cells.

I can access to this cells with
gridName(cell.RowIndex, cell.ColIndex)

but it's not working when I try to change the style of the cell.

I try to do this :
- in the sub new, after the affectation of the datasource
- in the sub form_Load
- in a sub who handles gridName.DrawCell
- in a sub who handles gridName.DrawCellBackground
- in a sub who handles gridName.DrawCurrentCellBorder

But nothing is working.

How must I do ?



1 Reply

JJ Jisha Joy Syncfusion Team November 25, 2008 09:59 AM UTC

Hi,

Thank you for posting query to us.

You have to handle QueryCellInfo to apply cell specific styles in GridDataBoundGrid. You can check for the Colindex and RowIndex to track the specific cell and set the styles.

Please refer the code:

//Event
this.gridDataBoundGrid1.Model.QueryCellInfo += new Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventHandler(Model_QueryCellInfo);

//Event Handler

void Model_QueryCellInfo(object sender, Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs e)
{
if (e.ColIndex == 2 && e.RowIndex == 2)
{
e.Style.BackColor = Color.BlueViolet;
e.Style.Borders.All = new GridBorder(GridBorderStyle.DashDotDot, Color.DarkCyan);
}
}

Please let me know if this helps.

Regards,
Jisha


Loader.
Live Chat Icon For mobile
Up arrow icon