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.
Up arrow icon