Board index » delphi » Delphi 7/SQL Server 200,ADO TDBGRID out of sync
Robert Carrington
![]() Delphi Developer |
Delphi 7/SQL Server 200,ADO TDBGRID out of sync2004-06-22 11:42:45 PM delphi226 I have 1 TDBGrid component and multiple TADOQuery objects that can be connected to it. Depending on where grid is accessed from a different query is connected to it. These queries are always open in the background regardless. The problem is that sometimes when trying to select a row in the grid it actually selects a completely different row. 2 indicators are shown on the indicator column as well. These can only be got rid of by selecting the row that was initially selected. This usually happens after the TDBGrid.DataSource.DataSet has been swapped several times and then returns to a dataset that has been open in the past. EXACT PROCESS: My grid is also read only and I have tried setting the rowselect and alwaysshowselection flags as well to no avail. My grid shows the results of a search (hence read only). The different datasets connected depend on the type of search (customer/funder/dealer etc). 1. Searched and selected random Contract 2. Searched and selected random Customer 3. Select random Contract. 4. Tried to select a random Customer (Contract and Customer use different datasets for search results) Then the following situation occurred when I tried to select a new Customer. The blue row highlight is on the wrong line but the indicator arrow is on the correct line. When I try to select another different row. The blue row highlight moves to yet another different row and I now have 2 indicator arrows. The original indicator arrow is only removed if I now select the row it is on. The grid starts working properly again after the first click. This seems like a bug to me in the TDBGrid component but I am surprised it hasn't come to light before. Is this a bug that anyone else has come across? I agree that it is not a particularly good method of doing things but it is still doing something that is apparently allowed by Delphi and it is not throwing any errors. Also there should be no possible way for a row other than the one you click on to be selected. I'd be interested if anyone else has/is able to replicate this as I have not seen anything about this on the net. I have tried various methods of refreshing/repainting and cannot get anything to work. NOTE: 1. I cannot just rewrite the code as it would have too large an impact on the rest of the program. 2. I cannot just close the query and reopen it as I wish to retain the position in the query. ). Rob |