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 do I change the Backcolor of a single row in a GridDataBoundGrid?


In a GridDataBoundGrid, you cannot set row specific properties like BackColor using the Model.RowStyles member like this.gridDataBoundGrid.Model.RowStyles[8].BackColor=Color.Red. The reason is that in a GridDataBoundGrid, the only data storage is the bound datasource. There is no row specific storage allocated. So, in order to set row specific properties in a GridDataBoundGrid, you must catch the PrepareViewStyleInfo event (or Model.QueryCellInfo event). In your handler, you check e.RowIndex, and if it points to the row you want to color, you set e.Style to the value you want. (The e.ColIndex > 0 check in the code avoids coloring the header cell in the row.)


private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)


if(e.ColIndex > 0 && e.RowIndex == 8)


e.Style.BackColor = Color.Red;




Private Sub gridDataBoundGrid1_PrepareViewStyleInfo(sender As Object, e As GridPrepareViewStyleInfoEventArgs)

If e.ColIndex > 0 And e.RowIndex = 8 Then

e.Style.BackColor = Color.Red

End If

End Sub



Article ID: Published Date: Last Revised Date: Platform: Control:
459 04/30/2011 07/10/2014 WinForms GridDataBoundGrid(Classic)
Did you find this information helpful?
Add Comment
You must log in to leave a comment

Please sign in to access our KB

or the page will be automatically redirected to sign-in page in 10 seconds.

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