dbgrid how to read value from cells

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
monster2Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kretzschmarCommented:
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
monster2Author Commented:
Thanks I'll try that tonight
0
monster2Author Commented:
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
kretzschmarCommented:
hi monster,

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

meikl ;-)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.