Windows Form DataGrid - Need A Color Border Around Only The Selected Row - Will GDI Be Required

R

Richard

I have a lot of colors, fonts, etc. to set for rows and possibly columns,
based on the information contained in the row and/or the selected row. A
main one is putting a border around the entire selected row only. The border
one does not seem to be simple thing to do by just setting a property of the
grid, DataGridTableStyle, GridColumnStyle, etc. It seems to require GDI
stuff like Paint, Brush, Region, Rectangle, etc. Is there an easier way than
all this custom GDI programming.

If custom programming is involved is there anyone who has sample of a nice
orderly, well structured object with best practices properties, methods,
etc. to do this type of thing? Or, failing that a good book recommendation.
Not a book that is really geared to heavy graphics but something like what
I'm looking to do with the DataGrid.
 
K

Ken Tucker [MVP]

Hi,

Maybe selecting the row will work for you.

Dim conn As SqlConnection

Dim strConn As String

Dim strSQL As String

Dim da As SqlDataAdapter

Dim ds As New DataSet

strConn = "Server = (local);"

strConn &= "Database = NorthWind;"

strConn &= "Integrated Security = SSPI;"



conn = New SqlConnection(strConn)

da = New SqlDataAdapter("Select * From Products", conn)

da.Fill(ds, "Products")

DataGrid1.DataSource = ds.Tables("Products")

For x As Integer = 0 To ds.Tables("Products").Rows.Count - 1

Dim dr As DataRow = ds.Tables("Products").Rows(x)

If CInt(dr.Item("UnitsInStock")) < 5 Then DataGrid1.Select(x)

Next



Ken

-----------------------
I have a lot of colors, fonts, etc. to set for rows and possibly columns,
based on the information contained in the row and/or the selected row. A
main one is putting a border around the entire selected row only. The border
one does not seem to be simple thing to do by just setting a property of the
grid, DataGridTableStyle, GridColumnStyle, etc. It seems to require GDI
stuff like Paint, Brush, Region, Rectangle, etc. Is there an easier way than
all this custom GDI programming.

If custom programming is involved is there anyone who has sample of a nice
orderly, well structured object with best practices properties, methods,
etc. to do this type of thing? Or, failing that a good book recommendation.
Not a book that is really geared to heavy graphics but something like what
I'm looking to do with the DataGrid.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top