changing the color of the entire row in datagrid when a cell in the row has value greater than zero

  • Thread starter Thread starter hemant
  • Start date Start date
H

hemant

hello everybody,

I am having a datagrid which has data regarding customers. it has a
penalty column, and i want to show the entire record of the customer
in red whose penalty is greater than zero.

i have looked into the other messages which guide to override the
paint procedure of the datagrid, make a new class etc.

i am not able to understand the exact way of doing the mentioned
things.

i'll be thankful if somebody pours in some help.

hemant.
 
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

-----------------------

hello everybody,

I am having a datagrid which has data regarding customers. it has a
penalty column, and i want to show the entire record of the customer
in red whose penalty is greater than zero.

i have looked into the other messages which guide to override the
paint procedure of the datagrid, make a new class etc.

i am not able to understand the exact way of doing the mentioned
things.

i'll be thankful if somebody pours in some help.

hemant.
 
hemant said:
hello everybody,

I am having a datagrid which has data regarding customers. it has a
penalty column, and i want to show the entire record of the customer
in red whose penalty is greater than zero.

i have looked into the other messages which guide to override the
paint procedure of the datagrid, make a new class etc.

i am not able to understand the exact way of doing the mentioned
things.

i'll be thankful if somebody pours in some help.

hemant.

I think if selecting the whole row is no good it'd be a hell of a lot easier
if you just highlit the textbox has the negative amount in it.
Check out george shepherd's faq site.
The datagrid section might have some ideas in it for you.

I suppose you could maybe mark an error in the row selector thing.
 

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

Back
Top