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.

Row BackColor

Thread ID:

Created:

Updated:

Platform:

Replies:

29182 May 18,2005 12:04 PM Nov 9,2005 08:37 AM Windows Forms 4
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On May 18, 2005 12:04 PM

Hi, I want to set the backColor of a row in a databoundgrid based on the value of a particular column. In the PrepareViewStyleInfo handler, I check for the value of this particular column. Now how can I set the backcolor of the entire row? e.Style.BackColor in the eventhandler will only change the color for that particlar cell. Can I do something like grid.Model.RowStyles[row].BackColor = ... I am concerned that this might trigger endless recursive calls to PrepareViewStyleInfo. Thanks,

Administrator [Syncfusion]
Replied On May 18, 2005 02:22 PM

You will have to use PrepareviewStyleInfo to do this. Try code like this in PrepareviewStyleInfo to color the whole row.
if(e.ColIndex > 0 && e.RowIndex > 0)
{
   int colIndex = grid.Binder.NameToCOlIndex("TestValue");
   object testValue = grid[e.RowIndex, colIndex].Cellvalue;
   if(testValue == xyz)
      e.Style.BackColor = Color.Red;
}

Administrator [Syncfusion]
Replied On November 8, 2005 12:09 PM

Hi Clay, Could you tell me which event I should use for a GridGroupingControl. Thanks. Seb >You will have to use PrepareviewStyleInfo to do this. > >Try code like this in PrepareviewStyleInfo to color the whole row. >
>if(e.ColIndex > 0 && e.RowIndex > 0)
>{
>   int colIndex = grid.Binder.NameToCOlIndex("TestValue");
>   object testValue = grid[e.RowIndex, colIndex].Cellvalue;
>   if(testValue == xyz)
>      e.Style.BackColor = Color.Red;
>}
>

Administrator [Syncfusion]
Replied On November 9, 2005 12:57 AM

Hi Seb, You can handle the TableControlPrepareViewStyleInfo event. Here is some code snippet: private void TableControl_PrepareViewStyleInfo(object sender, GridTableControlPrepareViewStyleInfoEventArgs e) { GridTableCellStyleInfo style = (GridTableCellStyleInfo) e.Inner.Style; if (style.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell || style.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell) { int colIndex=this.gridGroupingControl1.TableModel.NameToColIndex("Col1"); GridTableCellStyleInfo style1 = this.gridGroupingControl1.Table.GetTableCellStyle(e.Inner.RowIndex,colIndex); if(style1.Text =="row1 col1") e.Inner.Style.BackColor=Color.LightPink; } } Here is a sample. GC_BackColor.zip Let us know if this serves your purpose. Best Regards, Jeba

Administrator [Syncfusion]
Replied On November 9, 2005 08:37 AM

Thanks you very much Jeba .. this is exactly what I was looking for ... there is so many events that can be handled .. sometime I need a map or a guide :) Thanks also for being so quick to answer my question. Seb

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.

;