Re: Delphi7/ADO/SQL Server 2000 TDBGrid problem

From: Robert Carrington (rcarrington_at_ice-sys.co.uk)
Date: 06/21/04


Date: Mon, 21 Jun 2004 10:55:33 +0100

Thanks Morpheus unfortunately I've still had no luck.

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).
Your system seems remarkably similar in what it is doing to mine and yet I
am getting very strange results.

I have just tried it again and got this strange situation. Hopefully this
description is a bit better than my previous one:

1. Searched and selected random Contract
2. Searched and selected random Customer
3. Repeated 1.
4. Searched for 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.

This seems like a bug to me in the TDBGrid component but I'm surprised it
hasn't come to light before.

Rob

"Morpheus" <morpheusNOPSAM@redpoint.co.za> wrote in message
news:40d30d46@newsgroups.borland.com...
> Hi Robert,
> It's uncanny. I have pretty much the same setup in an app. I am working
on.
> I use this approach to edit what I call simple system tables. Thye are
> typically tables with two columns, a unique autoincrement ID column, and a
> column named Description. I have implemented the logic you allude to with
no
> problem.
> I have a TDBGrid on the left which retrieves a dataset from a view in the
> SQL DB. This view pulls out table names from systables and the Table
object
> comments field from sysproperties, in which I define the table name that
the
> user sees.
> When the user scrolls in this list, a tdbgrid to the right has its
> datasource.dataset connected to the appropriate TADODataset component on
my
> data module. I've never had the problem that you refer to. I do not even
> close and re-open tables when I am switching tables, and the record
pointers
> remain where they were when I last edited the table. The possible
difference
> is that I do not edit data in the grid. Because all of the editable
columns
> are called Description, I can safely make the grid read-only, and edit the
> selected row in a DBEdit. Works like a charm. My grid is therefore read
> only, and the Options set are:
> dgEditing=False
> dgRowSelect=True
> dgAlwaysShowSelection=True
> Maybe this will help.
> Incidentally, I detect the move in the grid listing the tables in either
the
> oncellclick event or in the onkeyup event, or in the OnMouseDown event,
> although I still have not gotten it to properly detect a right mosue
button
> click.
> Hope this might be of help.
> Regards,
> Morpheus
> "Robert Carrington" <rcarrington@ice-sys.co.uk> wrote in message
> news:40d04d0b@newsgroups.borland.com...
> > 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.
> >
> > 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 would 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. ).
> >
> >
>
>