Article View: borland.public.cppbuilder.database.ado
Article #3676Re: Sorting DBGrid
From: J.Steinecker
Date: Thu, 04 Jul 2002 12:58
Date: Thu, 04 Jul 2002 12:58
36 lines
2123 bytes
2123 bytes
Hi, if you use a TQuery as DataSet you can search the SQL->Text AnsiString for an ORDER BY. If you cannot find an ORDER BY then you can append one with the column->FieldName. If you find an ORDER BY then you can do different ways. In case it is the same column I change the sort order from ascending to descending or vice versa. In the other case you can change the sort column. After that I close and reopen the manipulated query to do the sorting. You have to think about some problems. You can have comments in the SQL statement what you have to take into consideration on searching for the ORDER BY. If you use calculated fields in your query then you get the gridname in the OnTitleClick event, but on which column is to sort? So I provided a method to produce an additional list which makes a mapping between gridcolumns and querycolumns. HTH Juergen "Ola Eriksen" <ola@callcom.no> schrieb im Newsbeitrag news:1103_1025773874@ola... > Hello! > > A simple question I guess :) > > Can anyone help me with some code so that I can sort the TDBGrid by the field the user selects. > I've activated the OnTitleClilck event, but I've not managed to write a code that works :( > > Thanks! > >
Technical Details
Message-ID:
<3d245a1e_2@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-08!supernews.com!peer.news.opaltelecom.net!iad-peer.news.verio.net!news.verio.net!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!dnewsReferences:
<1103_1025773874@ola>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,6f893f24f32b7eae X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2002-07-04 07:43:47 PST From: "J.Steinecker" <jsteinecker@gmx.de> Newsgroups: borland.public.cppbuilder.database.ado References: <1103_1025773874@ola> Subject: Re: Sorting DBGrid Date: Thu, 4 Jul 2002 14:58:45 +0200 Lines: 38 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 NNTP-Posting-Host: 130.78.143.1 Message-ID: <3d245a1e_2@dnews> X-Trace: dnews 1025792542 130.78.143.1 (4 Jul 2002 07:22:22 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-08!supernews.com!peer.news.opaltelecom.net!iad-peer.news.verio.net!news.verio.net!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!dnews