Link to home
Start Free TrialLog in
Avatar of Victor  Charles
Victor CharlesFlag for United States of America

asked on

Help with hiding rows in DataGridView

Hi,

I'm trying to hide certain rows in DataGridView depending on items selected on a Combobox, when select the second row of the Combox a second time, I receive the following error:

Row associated with the currency manager's position cannot be made invisible.

On line:

Me.DataGridView5.Rows(i).Visible = False


  Dim i As Integer
        If C1AEDL.SelectedIndex = 0 Then
            For i = 0 To 2
                Me.DataGridView5.Rows(i).Visible = False
            Next
        End If
        If C1AEDL.SelectedIndex = 1 Then
            For i = 3 To 5
                Me.DataGridView5.Rows(i).Visible = False
            Next
        End If

How do I fix this problem? Don't understand why the error does not occur the first time it was selected.

Thanks,

Victor
Avatar of plusone3055
plusone3055
Flag of United States of America image

Dim i As Integer
        If C1AEDL.SelectedIndex = 0 Then
            For i = 0 To 2
                Me.DataGridView5.Rows(i).Visible = False
            Next
   
    else If C1AEDL.SelectedIndex = 1 Then
            For i = 3 To 5
                Me.DataGridView5.Rows(i).Visible = False
            Next
        End If
Avatar of Victor  Charles

ASKER

Thanks for the code but the same error still appears.
what does 1 mean?
ASKER CERTIFIED SOLUTION
Avatar of John (Yiannis) Toutountzoglou
John (Yiannis) Toutountzoglou
Flag of Greece 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
Thank You.