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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Row BackColor

Thread ID:

Created:

Updated:

Platform:

Replies:

29182 May 18,2005 04:04 PM UTC Nov 9,2005 01:37 PM UTC WinForms 4
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On May 18, 2005 04:04 PM UTC

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 06:22 PM UTC

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 05:09 PM UTC

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 05:57 AM UTC

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 01:37 PM UTC

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.

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

;