Link to home
Start Free TrialLog in
Avatar of bertino12
bertino12

asked on

Select a row for highlighting - Gridview control with checkbox

I have a checkbox column in my gridview control. I want to make it so on checkchanged it selects the row or deselects the row so the row is highlighted. Here is the code I have so far. I just need to select the row now.

    Protected Sub CheckBox1_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
        Dim CB As CheckBox
        CB = CType(sender, CheckBox)

        If CB.Checked = True Then
            'select the row so its highlighted
        ElseIf CB.Checked = False Then
            'unselect the row so its no longer highlighted
        End If
    End Sub
ASKER CERTIFIED SOLUTION
Avatar of chinu1310
chinu1310
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Protected Sub CheckBox1_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
        Dim CB As CheckBox
        CB = CType(sender, CheckBox)

        If CB.Checked = True Then
            //I'm doing a cast on CheckBox parent to GridViewRow and then setting its color, do this in VB
            ((GridViewRow)CB.parent).BackColor = System.Drawing.Color.Red; //C# code, you must fit to VB
        ElseIf CB.Checked = False Then
           //I'm doing a cast on CheckBox parent to GridViewRow and then setting its color, do this in VB
           ((GridViewRow)CB.parent).BackColor = System.Drawing.Color.White; //C# code, you must fit to VB
        End If
    End Sub

Regards, Rodrigo Leote