I have a splitcontainer that has a number of different controls in the panels. I would like to dynamically remove the datagridview if it is in the splitcontainer. While this code exicutes and gives no errors it does not remove the datagridview.
For i = scExspenses.Panel1.Controls.Count - 1 To 0 Step -1
If TypeOf scExspenses.Panel1.Controls(i) Is DataGridView Then
scExspenses.Controls.Remove(scExspenses.Panel1.Controls(i))
End If
Next
I know that I can remove all controls with scExspenses.Controls.Clear() but I do not want to destroy the other controls that are in the splitcontainer panel