I am trying to filter data in a DataGridView and I need to hide all rows and columns. I try to do this using looping list LINQ & lambda expressions because if I use a foreach it is slow when I try to filter 3000 rows.
The following code executes without errors and works perfectly in c# but doesn't hide the rows in vb:
c# works perfectly
dataGridView1.Columns.OfType<DataGridViewColumn>().ToList().ForEach(col => col.Visible = false);
vb doesnt works not hide the rows
datagrid.Rows.OfType(Of DataGridViewRow)().ToList().ForEach(Function(obj) obj.Visible = False)
when i change Function by Sub send me error
datagrid.Rows.OfType(Of DataGridViewRow)().ToList().ForEach(Sub(obj) obj.Visible = False)
I'm looking for the equivalent code C# to vb or the action equivalent.