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.
Unfortunately, activation email could not send to your email. Please try again.

How Change the color of a Row - GridControl

Thread ID:

Created:

Updated:

Platform:

Replies:

44137 May 15,2006 09:33 AM May 18,2006 08:41 AM Windows Forms 3
loading
Tags: GridControl
Ravichandran
Asked On May 15, 2006 09:33 AM

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 12:06 AM

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 04:01 AM

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 08:41 AM

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.

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.

;