.netvb.netdatagridviewcurrencymanager

Hiding DataGridView Row 0 produces error


In my DataGridView, it fails to hide a row, if that row is index 0.

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

Dim cm1 As CurrencyManager = CType(BindingContext(dgv.DataSource), CurrencyManager)
cm1.SuspendBinding()
dgv.Rows.Item(0).Visible = False 'this throws the exception

Solution

  • From my understanding I believe if that's the only row left and it's selected the row or cell must be visible. To get around this you could possibly setting the current cell to null then SuspendBinding...

    Here's a simple example...

     Me.dgv.CurrentCell = Nothing
     Me.cm1.SuspendBinding()
     Me.dgv.Rows(index).Visible = False