How do I set the BackColor for GDBG from outside the control?

I would like to be able to set the CurrentCell''s background color without having to handle the QueryCellInfo event. I tried: gdbg.Model[rowNdx, colNdx].BackColor = Color.Plum; where rowNdx and colNdx point to the CurrentCell, but no color is ever set.

3 Replies

AD Administrator Syncfusion Team January 10, 2006 05:51 AM UTC

Hi, you can use PrepareViewStyleInfo Event for changing the current cell''s background color of GDBG. Here is the Code snippet. private void gridControl1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e) { if(e.ColIndex == 3 && e.RowIndex == 3) e.Style.BackColor = Color.Yellow; } Refer this KB article for more details. http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=84 With Regards, Madhan


ST stanleyj Syncfusion Team January 10, 2006 06:53 AM UTC

Hi, To have only the current cell to be of any color, then CurrentCell.HasCurrentCellAt(e.RowIndex, e.ColIndex) has to be checked in the PrepareViewStyleInfo or QueryCellInfo handler. if(this.gridDataBoundGrid1.CurrentCell.HasCurrentCellAt(e.RowIndex, e.ColIndex)) { e.Style.BackColor = Color.Pink; } Best regards, Stanley


JM Jay Mooney January 10, 2006 02:51 PM UTC

I was looking for a way to do this outside of any event. Looks like maybe that can''t be done.

Loader.
Up arrow icon