The application is written in VB6 using dxdbGrid control. While setting focus to any record in the top rows takes no time, setting focus to any record near the bottom of the grid or the end of the list take quite a while. The list has only 400 records but it takes about 10-15 seconds. The question is what is really happening in the process of setting focus to a particular row. Thanks for your help!
Here is the sample code:
Public Sub ApplyGridSettings(ByRef Grid As dxDBGrid, ByRef gSettings As GridSettings)
Dim Node As dxGridNode
Dim i As Long
For i = 0 To gSettings.selectedcount - 1
Set Node = Grid.m.FindNodeByKeyValue(gSettings.SelectedNodes(i))
If Not Node Is Nothing Then
Node.Selected = True
Set Node = Grid.m.FindNodeByKeyValue(gSettings.FocusedID)
If Not Node Is Nothing Then
Node.Focused = True ' <----- this takes a long time when the node is near the bottom of the grid.
Grid.ex.topindex = Node.AbsoluteIndex - gSettings.FocusedIndex
I'm afraid this information isn't sufficient to precisely identify the cause of the problem. Which data source are you using for your Grid? If this is an external recordset, please bind it to a standard MS DataGrid, and try to navigate its rows. What are you results?
If you're using the Grid's internal data sources (ADODataset, Unbound Mode or Memory Data), please verify that you don't perform time-consuming operations when navigating through the Grid. Reset all its event handlers to see whether the problem disappears. Then, restore them one-by-one to detect when it comes back.
In any case, please keep me informed about your progress.
Thanks for replying!
The grid is binding to an internal ADODataset recordset that was returned from a stored procedure in SQL. To be simple, What I try to do is to update the selected record in the database with certain data when the user clicks on that record in the grid.
The way the code is written now is that it first closes the grid's dataset (grid.dataset.close), finds and updates the selected record in the recordset, re-open the grid's dataset (grid.dataset.open) and calls that ApplyGridSettings to select and set focus back to the row (or rows) that was clicked on. For some reasons, setting Node.Focused = true takes quite a while to complete.
Let me ask another question: when I click on a row in the grid, does it move the cursor to where the record is in the recordset internally?
Thanks again for your help!
Sorry, it took us significant time to research the situation. Unfortunately, our tests don't produce such delays. Perhaps there are other things involved at your end. Could you please supply us with a sample project demonstrating this problem? We can then take a look at it, and try to find a solution.
Is your intention to post an answer to your own question?
- If so, then proceed.
- If you simply wanted to post additional information, ask for further clarification, or to just say "Thanks!", please click Leave a Comment.
- If you wish to edit your original question, please use the Edit button in the Toolbox at the top right corner of that entry.