Results 1 to 5 of 5

Thread: datagrid row

  1. #1

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075

    datagrid row

    I need to change the color of a row when my form loads. I'm using the following code, but it changes the color of all the rows...any suggestions?


    VB Code:
    1. Dim i As Integer
    2.         With ds.Tables("checks")
    3.             For i = 0 To .Rows.Count - 1
    4.                 If .Rows(i)("check_no") = "2" Then
    5.                     dgView.BackColor = Color.Red
    6.                 End If
    7.             Next
    8.         End With
    It's tough being an unhandled exception...

    ___________
    VB.NET 2008
    VB.NET 2010
    ORACLE 11g
    CRYSTAL 11

  2. #2

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075

    Re: datagrid row

    help
    It's tough being an unhandled exception...

    ___________
    VB.NET 2008
    VB.NET 2010
    ORACLE 11g
    CRYSTAL 11

  3. #3
    Lively Member smartrajesh's Avatar
    Join Date
    Feb 2005
    Posts
    94

    Re: datagrid row

    simple man u just avoid use the for loop

    like

    With ds.Tables("checks")
    If .Rows(i)("check_no") = "2" Then
    .row=2
    dgView.BackColor = Color.Red
    End If
    End With
    bye

  4. #4
    Hyperactive Member Lil Ms Squirrel's Avatar
    Join Date
    Nov 2004
    Location
    planet squirrel
    Posts
    494

    Re: datagrid row

    As I said in my response to one of your other posts about this subject, you need to work on your own custom data grid column to allow rows to have different back colours.

    In a nutshell, you override the Paint event for the cell as it is painted. If you really really can't work the code out from the other sample then PM me and I'll work something out for you later this evening.
    Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind.
    Dr. Seuss

  5. #5
    Frenzied Member maged's Avatar
    Join Date
    Nov 2002
    Location
    Egypt
    Posts
    1,040

    Re: datagrid row

    Lil Ms Squirrel, i have done that several times but i could only change the forecolor and backcolor of a total column. i have never got to control a single cell property. why?? because ,

    when you override the paint method it is easy to color a column according to it's index ( ordinal no. ) but with specific cells it is very hard as i don't know how much rows are there in the grid nor do i know if the user have arranged them by clicking any column headers. moreover if i have several cells to be painted in different locations. how can i select them without changing the color of the other cells in the grid

    that is the question

    Thx in advance

    RGDS

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width