?
Solved

dbgrid how to read value from cells

Posted on 1999-11-30
4
Medium Priority
?
440 Views
Last Modified: 2010-04-04
I made a simple app which uses dbgrid tquery and datasource
I fill the dbgrid with sql querry and that part is OK.

how can I:
1. read data values containd in cells

let say i wont to know name containd in cell 'name' at place nr.5

2. How can i find out number of records (not cells) which query returned in dbgrid.

3. How can I disable scroll bars and select options in dbgrid I wont to use only dbnavigator to move trough records in dbgrid


That's all folks

  Regards
0
Comment
Question by:monster2
  • 2
  • 2
4 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2245980
hi monster2

to 1.)

procedure TForm1.Button1Click(Sender: TObject);
begin
  //shows the value of the current field
  ShowMessage(DBGrid1.SelectedField.AsString);
  //shows the value of the 5th Column
  ShowMessage(DBGrid1.Columns[4].Field.AsString);
  //shows the value of a specific Field of the current record
  ShowMessage(DBGrid1.Datasource.Dataset.FieldByName('Name').AsString);

end;

to 2.)

procedure TForm1.Button2Click(Sender: TObject);
begin
  showMessage(IntToStr(query1.RecordCount));
  //maybe you must perform a query1.Last or query1.FetchAll
  //before the count is properly
end;

to 3.)

procedure TForm1.Button3Click(Sender: TObject);
begin
  //hide the scrollbars, maybe also to include in the afterscroll-event of the dataset
  showScroLLBar(dbgrid1.handle,sb_both,LongBool(false));
end;

meikl
0
 

Author Comment

by:monster2
ID: 2246293
Thanks I'll try that tonight
0
 

Author Comment

by:monster2
ID: 2249867
Thanks again (i try to use accept comment as answer yesterday but look's like i made a error)
please take points for You answer

Regards
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 120 total points
ID: 2250475
hi monster,

not at all, i answer this.
glad to helped you
good luck again

meikl ;-)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video I will demonstrate how to set up Nine, which I now consider the best alternative email app to Touchdown.
Get the source code for a fully functional Access application shell with several popular security features that Access VBA application developers desire, but find difficult or impossible to figure out how to code. You get the source code for managi…
Suggested Courses
Course of the Month6 days, 18 hours left to enroll

593 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question