Coloring a datagridview


Author
Message
Thomas Holste
Thomas Holste
StrataFrame User (354 reputation)StrataFrame User (354 reputation)StrataFrame User (354 reputation)StrataFrame User (354 reputation)StrataFrame User (354 reputation)StrataFrame User (354 reputation)StrataFrame User (354 reputation)StrataFrame User (354 reputation)StrataFrame User (354 reputation)
Group: StrataFrame Users
Posts: 144, Visits: 618
Hi There,

I am trying to color rows in a grid depending on a special value in a database field.

What I haven't yet figured out is how I can do this depending on a BO-Value and not a

cell-value.

For example: I have a datagridview with a BBS as datasource which is connected to a BO.

In this BO I have a field called "isdeleted" and I want to show all coresponding lrows with the forecolor set to red.

What I do now is the following: I have added an invisible column with this field to the datagridview and have a little sub which colors the rows:



Private Sub setgridcolor()

For I As Integer = 0 To kundengrid.Rows.Count - 1

   If kundengrid.Rows(I).Cells("IsDeleted").Value = "J" Then

      kundengrid.Rows(I).DefaultCellStyle.ForeColor = Color.Red

   End If

Next

End Sub



And then I call this sub in the paint-event of the datagridview.

Everything works fine but somehow it does not feel right and I would like to know how this can be done better?

Thanks in advance

Thomas
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search