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

How Change the color of a Row - GridControl

I am using virtual GridControl. How to change the BG color of the row. ( I want to change the color when i am about to edit the row to yellow.) Thanks & Regards Chandr.

3 Replies

AD Administrator Syncfusion Team May 16, 2006 04:06 AM UTC

Hi Ravichandran, To change the color of the editing row ,You need to handle the PrepareViewStyleInfo event.Here is a code snippet. //Form Load... this.gridControl1.RefreshCurrentCellBehavior = GridRefreshCurrentCellBehavior.RefreshRow; int rowIndex = -1; private void gridControl1_CurrentCellStartEditing(object sender, System.ComponentModel.CancelEventArgs e) { rowIndex = this.gridControl1.CurrentCell.RowIndex; this.gridControl1.RefreshRange(GridRangeInfo.Row(rowIndex)); } private void gridControl1_CurrentCellEditingComplete(object sender, System.EventArgs e) { rowIndex = -1; } private void gridControl1_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e) { if(e.ColIndex > 0 && e.RowIndex == rowIndex) { e.Style.BackColor = Color.Yellow; } } Please let me know if this helps. Best Regards, Haneef


RA Ravichandran May 16, 2006 08:01 AM UTC

Haneef, Thanks for your help it works fine. Cheers Ravi >Hi Ravichandran, > >To change the color of the editing row ,You need to handle the PrepareViewStyleInfo event.Here is a code snippet. > >//Form Load... >this.gridControl1.RefreshCurrentCellBehavior = GridRefreshCurrentCellBehavior.RefreshRow; > >int rowIndex = -1; >private void gridControl1_CurrentCellStartEditing(object sender, System.ComponentModel.CancelEventArgs e) >{ > rowIndex = this.gridControl1.CurrentCell.RowIndex; > this.gridControl1.RefreshRange(GridRangeInfo.Row(rowIndex)); >} > >private void gridControl1_CurrentCellEditingComplete(object sender, System.EventArgs e) >{ > rowIndex = -1; >} > >private void gridControl1_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e) >{ > if(e.ColIndex > 0 && e.RowIndex == rowIndex) > { > e.Style.BackColor = Color.Yellow; > } >} > >Please let me know if this helps. >Best Regards, >Haneef


RA Ravichandran May 18, 2006 12:41 PM UTC

Haneef, Once again i am opening this thread.... It works fine if I use mouse to move next row..But when I use normal up or down arrow key the code I wrriten private void EditableGrid_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e) { if (e.RowIndex > 0 && (e.RowIndex - 1 == m_currentRowIndex)) { e.Style.BackColor = Color.LightYellow; } } is not working... How to change the color of the row even I move using up and down arrow key.. Thanks Ravi. >Haneef, > >Thanks for your help it works fine. > >Cheers >Ravi > >>Hi Ravichandran, >> >>To change the color of the editing row ,You need to handle the PrepareViewStyleInfo event.Here is a code snippet. >> >>//Form Load... >>this.gridControl1.RefreshCurrentCellBehavior = GridRefreshCurrentCellBehavior.RefreshRow; >> >>int rowIndex = -1; >>private void gridControl1_CurrentCellStartEditing(object sender, System.ComponentModel.CancelEventArgs e) >>{ >> rowIndex = this.gridControl1.CurrentCell.RowIndex; >> this.gridControl1.RefreshRange(GridRangeInfo.Row(rowIndex)); >>} >> >>private void gridControl1_CurrentCellEditingComplete(object sender, System.EventArgs e) >>{ >> rowIndex = -1; >>} >> >>private void gridControl1_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e) >>{ >> if(e.ColIndex > 0 && e.RowIndex == rowIndex) >> { >> e.Style.BackColor = Color.Yellow; >> } >>} >> >>Please let me know if this helps. >>Best Regards, >>Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon