Avatar of vcharles
vcharles 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
.NET ProgrammingVisual Basic.NET

Avatar of undefined
Last Comment
vcharles

8/22/2022 - Mon
plusone3055

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
ASKER
vcharles

Thanks for the code but the same error still appears.
plusone3055

1
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
ASKER
vcharles

what does 1 mean?
ASKER CERTIFIED SOLUTION
John (Yiannis) Toutountzoglou

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
vcharles

Thank You.