I have a listBox than contains values from a dataTable.
I also have a DataGrid that is populated based on the listBox.SelectedValue (value used as the dataAdaptor.SelectCommand.Parameter that populates the datatable the dataGrid is bound to). So every time a selected value in the listBox is changed, the contents of the dataGrid change accordingly.
Say the dataGrid lists 5 rows, the user puts the curser in (any) cell on the last row, then selects another value in the listBox. This then generates say only 3 rows. The problem is that the cell which was previously clicked on remains visible. Just that cell!
This problem applies to any cell clicked on, in any row that is greater than the new list. If it is less than, then the new (greater number of) rows overwrites the problem, then all is good. It is if the dataGrid is not clearing itself properly. Any suggestions on how to resolve this issue?
This method I have used to re-populate the dataGrid:
Private Sub listBox_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles listBox.SelectedIndexChanged
MyDataAdaptor.SelectCommand.Parameters("@Column").Value = CType(Me.listBox.SelectedValue, DataRowView)( listBox.DisplayMember.ToString).ToString()