Question : Delete rows from datagrid when = to variable

Hi, I want to display data from a database, but to filter the data, by a column called BranchID. The data currently fills the dataset and poppulated the datagrid with data from three different BranchID's. I want a variable (branch) to be passed from the login dialogue (which all currently happens fine) to determine the data displayed in the datagrid.

The error occurs when trying to remove rows from the datagrid
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
For Each i As DataGridViewRow In DataGridView1.Rows
 
            If Not i.Cells.Item(0).Value = branch Then
 
                DataGridView1.Rows.Remove(i)
 
            Else

Answer : Delete rows from datagrid when = to variable

>>that variable is then passed to the main form
Can you describe that process, please?

Bob
Random Solutions  
 
programming4us programming4us