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

GridDataBoundGrid

Is there any way I can set column header styleInfo
dynamically, and how about based on the level in GridDataBoundGrid?

Thanks

1 Reply

AD Administrator Syncfusion Team August 29, 2006 05:18 AM UTC

Hi Ken,

You can handle the PrepareViewStyleInfo event of the grid to do this. Try the below code snippet.

private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
GridBoundRecordState state = this.gridDataBoundGrid1.Binder.GetRecordStateAtRowIndex(e.RowIndex);
int levelIndex = state.LevelIndex;

if (levelIndex == 0 && e.RowIndex <= this.gridDataBoundGrid1.Model.Rows.HeaderCount && e.ColIndex > 0)
e.Style.BackColor = Color.Plum;

else if (levelIndex == 1 && e.RowIndex <= this.gridDataBoundGrid1.Model.Rows.HeaderCount && e.ColIndex > 0)
e.Style.BackColor = Color.AliceBlue;

else{}
}

Let me know if you need any further assistance.
Regards,
Rajagopal

Loader.
Live Chat Icon For mobile
Up arrow icon