I used the datagrid click event to show the values in a particular row of the datagrid in text boxes below the grid.
But the problem is I have to double click the row where as i have used the single click event.
Can someone provide me a hint.
Use the RowColChange event instead, and this will fire when the user uses the ARROWS or TAB to move to another row/column (depending what the grid's tab navigation property is set to)
Then you should already have a recordset with the records used to fill the grid with and can do a search with-in that same recordset using the FIND method, and get the data from there.
(unless you are doing Paging)
Also, you could just take the cell values from the grid.
Another method, my favorite, is to use the recordset's bookmark property to locate the selected record.
And even this can be done automatically so that the movement in the grid keeps the recordset in sync. No FINDs/Searches needed at all.
Here's a tip for HFlex grid users who fill the grid with records from a recordset using the ADO client cursor manager:
When filling the grid, while looping through the recordset, (or, if you used the DataSource or Recordset property of the grid in order to automatically fill it, you will need to make an initial loop through all grid rows), set the flex grid's RowData property to the Recordset's BookMark property.
Then in the RowColChange event, use something like:
If Val(.RowData(.Row)) > 0 Then m_rsADO.Bookmark = CDbl(.RowData(.Row))
Now the recordset should stay in sync when navigating in the grid.
To do this the other way around, when the recordset is repositioned, you can use then recordset's absolute position property and add this the the row number of the first row with a record (eliminating header rows) and call the grid's Row method.
Declaring the recordset using WithEvents also helps, because you can the reposition the grid from the recordset's MoveComplete event with one or two lines of code.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.