DataGridView change row color

Discussion in 'Microsoft Dot NET Framework Forms' started by Tony B, Apr 19, 2006.

  1. Tony B

    Tony B Guest

    Hi,
    I'm trying to change the background color of a row in a DataGridView
    based upon a value in one of the row columns

    For i As Integer = 0 To myDataGridView.Rows.Count - 1
    If CInt(myDataGridView.Rows(i).Cells(12).Value) = 2 Then

    myDataGridView.Rows(i).DefaultCellStyle.BackColor = Color.Red

    End If
    Next

    I've stepped through the code so I know that the value of cell 12 is
    being pulled out and the line
    myDataGridView.Rows(i).DefaultCellStyle.BackColor = Color.Red
    is executed but the background color isn't changed.

    Any suggestions?

    Tony
     
    Tony B, Apr 19, 2006
    #1
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    1,121
  2. Guest

    Making DataGridView do row-by-row edit instead of cell-by-cell

    Guest, May 1, 2006, in forum: Microsoft Dot NET Framework Forms
    Replies:
    4
    Views:
    494
    Guest
    Jun 23, 2006
  3. Forcing DataGridView to repaint a row/disabling a row

    , Sep 15, 2006, in forum: Microsoft Dot NET Framework Forms
    Replies:
    1
    Views:
    439
  4. DataGridView paste to (edit row), * row

    , Nov 6, 2006, in forum: Microsoft Dot NET Framework Forms
    Replies:
    0
    Views:
    304
  5. Earl

    Row highlight after deleting row in datagridview

    Earl, Nov 30, 2006, in forum: Microsoft Dot NET Framework Forms
    Replies:
    0
    Views:
    184
Loading...

Share This Page