Yorkshireman2
Programmer
All the jobs here seem to want .net skills so I'm trying to learn it by writing one of my vb6 apps in vb.net.
In vb6 I had a datagrid bound to a recordset and using the recordset "find" method it automatically selected that row (if found) AND selected the datagrid row AND set that row to the top of the grid AND put the row marker on that row.
ALSO, you could supply a SQl string to the "Find" method and thus search on any column.
I am tearing my hair out in vb.net... I spent a whole day trying to do this.
In my new vb.net program, I have a datatable bound to a datagridview. I found the datatable.defaultview.find() method BUT it ONLY works on the primary key; luckily it's the primary key I need!
However, try as I might, once that method returns the found row index it DOES NOT set that datagridview row to the top.
I then found I could set the datagridview's "FirstDisplayedScrollingRowIndex" property to the row index returned by the find method and that at least puts the datagrid row of the index from the find method to the top.
BUT... even though the top row now shows the required row, that datarow is not really selected in the datatable or datagrid., because:
1. the row marker does not appear
and 2. the other data related to the current row (displayed in databound textboxes and comboboxes) does not update! it remains the same as before I tried searching for a row.
So- apart from Microsoft making all this way more complicated than vb6 was, is there actually a way to do this or have they made vb.net useless??
Any help welcome.
In vb6 I had a datagrid bound to a recordset and using the recordset "find" method it automatically selected that row (if found) AND selected the datagrid row AND set that row to the top of the grid AND put the row marker on that row.
ALSO, you could supply a SQl string to the "Find" method and thus search on any column.
I am tearing my hair out in vb.net... I spent a whole day trying to do this.
In my new vb.net program, I have a datatable bound to a datagridview. I found the datatable.defaultview.find() method BUT it ONLY works on the primary key; luckily it's the primary key I need!
However, try as I might, once that method returns the found row index it DOES NOT set that datagridview row to the top.
I then found I could set the datagridview's "FirstDisplayedScrollingRowIndex" property to the row index returned by the find method and that at least puts the datagrid row of the index from the find method to the top.
BUT... even though the top row now shows the required row, that datarow is not really selected in the datatable or datagrid., because:
1. the row marker does not appear
and 2. the other data related to the current row (displayed in databound textboxes and comboboxes) does not update! it remains the same as before I tried searching for a row.
So- apart from Microsoft making all this way more complicated than vb6 was, is there actually a way to do this or have they made vb.net useless??
Any help welcome.