Using the following code i can dynamicaly filter the rows of a datagridview that is connected with a datasource which is a datatable
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
DirectCast(DataGridView1.DataSource, DataTable).DefaultView.RowFilter = String.Format("userid like '%{0}%' or shortcut like '%{0}%' or command like '%{0}%'", TextBox1.Text)
End Sub
When i tried to use the same in a datagridview which is not connected whith a specific datasource but its rows where populated by using a loop such ass DataGridView2.Rows.Add(....) i get an object reference is not an instance of an object
Why is this happening;