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. (Last updated on : November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How Change the color of a Row - GridControl

Thread ID:

Created:

Updated:

Platform:

Replies:

44137 May 15,2006 01:33 PM UTC May 18,2006 12:41 PM UTC WinForms 3
loading
Tags: GridControl
Ravichandran
Asked On May 15, 2006 01:33 PM UTC

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.

Administrator [Syncfusion]
Replied On 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

Ravichandran
Replied On 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

Ravichandran
Replied On 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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;