Article View: borland.public.cppbuilder.database.ado
Article #3049Re: How to select by code all records in a DBGrid?
From: Alen Markov
Date: Sat, 04 Jan 2003 12:03
Date: Sat, 04 Jan 2003 12:03
104 lines
3927 bytes
3927 bytes
Hey Dan
Awesome! Thanks to you, now I was able to fill my combo like this:
//------------------------------------------------------------------------
void __fastcall TForm1::FormShow(TObject *Sender)
{
//Get Total number of rows:
int iRows = ADOQuery1->RecordCount;
for(int i=0; i<iRows; i++)
{
if(i == 0)
{
//Items[1] means 2nd Column in DBGrid...
//(1st Column was just primary key here in
ComboBox1->Items->Add(DBGrid1->Columns->Items[1]->Field->AsString);
}
else
{
ADOQuery1->MoveBy(1);
ComboBox1->Items->Add(DBGrid1->Columns->Items[1]->Field->AsString);
}
}
ADOQuery1->First();
}
//--------------------------------------------------------------------------
-
"Dan Greer" <info@pmicp.com> wrote in message
news:3e162daa$1@newsgroups.borland.com...
> Alen,
>
> You could try the "MoveBy(x)" method of your dataset.
>
> if will move the position forward or backward and from you current
position.
>
> Example:
>
> Query1->First(); // Set to the first record
> Query1->MoveBy(5); // move to the 5th record (row)
> Query1->MoveBy(-1); // moves to the 4th record (row)
> Query1->MoveBy(6); // moves to the 10th record (row)
>
> It look confusing, but with some work you could make it easier.
>
> dang
>
>
> "Alen Markov" <NOSPAM_amarkov@gmx.net> wrote in message
> news:3e15e83a$1@newsgroups.borland.com...
> > I'm still "fighting" with that DBGrid:
> >
> > I need to copy the content of one column of the DBGrid to a combobx
> >
> > 1.)
> > Let's say I have a DGBrid with a few rows displayed.
> > I can select a few rows by mouse and then I know how to copy the
> > SELECTED rows (of a particular column) to the combobox.
> > (an example can be easily found in the Builders helpfile...)
> >
> > But thist must happen at programstart (Event OnShow from the form),
> > means I need somehow to select all the rows in the DBGrid automatically.
> >
> > How to select all records in a DBGrid by programmcode?
> >
> >
> > 2.)
> > Another approach how to fill the combobox with rows displayed in a
column
> > of a DBGrid would be, If I would know how to access for example
> > in column number 0 the row number 3...
> >
> > I've found out that I can access column number 0, row number 0
> > for example like this:
> >
> > void __fastcall TForm1::Button2Click(TObject *Sender)
> > {
> > Label1->Caption = DBGrid1->Columns->Items[0]->Field->AsString;
> > }
> >
> > But how to access rows number 1, 2, 3 and so on...?
> >
> >
> >
> >
> > Any hint would be greatly appreciated...
> >
> >
> > Thanks a lot in advance and best regards
> >
> > Alen
> >
> >
> >
> >
> > --
> > WEB: http://www.come.to/nostromo
> >
> >
>
>
Technical Details
Message-ID:
<3e16cd93$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!newshosting.com!news-xfer1.atl.newshosting.com!news.stealth.net!news.stealth.net!newsfeed.icl.net!newsfeed.fjserv.net!opentransit.net!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3e15e83a$1@newsgroups.borland.com> <3e162daa$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,13f65491e8885df5 X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2003-01-04 04:10:07 PST From: "Alen Markov" <NOSPAM_amarkov@gmx.net> Newsgroups: borland.public.cppbuilder.database.ado References: <3e15e83a$1@newsgroups.borland.com> <3e162daa$1@newsgroups.borland.com> Subject: Re: How to select by code all records in a DBGrid? Date: Sat, 4 Jan 2003 13:03:13 +0100 Lines: 106 X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 80.218.79.120 Message-ID: <3e16cd93$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1041681811 80.218.79.120 (4 Jan 2003 04:03:31 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!newshosting.com!news-xfer1.atl.newshosting.com!news.stealth.net!news.stealth.net!newsfeed.icl.net!newsfeed.fjserv.net!opentransit.net!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail