* * *

Author Topic: How to go first row and first colum in DBGrid?!?!  (Read 1252 times)

majid.ebru

  • Sr. Member
  • ****
  • Posts: 268
How to go first row and first colum in DBGrid?!?!
« on: August 09, 2017, 11:43:48 am »
Hi
.
after i insert data to databank , the cursore of DBGrid goes to last colum and last row.
.
how can i go(set or setfuce or ....) to the first colums and first rows??
.
Thankyou

majid.ebru

  • Sr. Member
  • ****
  • Posts: 268
Re: How to go first row and first colum in DBGrid?!?!
« Reply #1 on: August 10, 2017, 08:11:06 pm »
Hi

i find answer here

Code: Pascal  [Select]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3.   with TStringGrid(DBGrid1) do
  4.   begin
  5.     Row := 2;
  6.     Col := 5;
  7.     SetFocus;
  8.   end;
  9. end;
  10.  

Handoko

  • Hero Member
  • *****
  • Posts: 1730
  • My goal: build my own game engine using Lazarus
Re: How to go first row and first colum in DBGrid?!?!
« Reply #2 on: August 10, 2017, 08:31:23 pm »
Did it work?

I checked the documentation. Although they both share the same ancestor TCustomGrid, but TDBGrid is not a descendent of TStringGrid.
http://lazarus-ccr.sourceforge.net/docs/lcl/grids/tstringgrid.html
http://lazarus-ccr.sourceforge.net/docs/lcl/dbgrids/tdbgrid.html

I think it is better to use:
with TCustomGrid(DBGrid1) do

mangakissa

  • Hero Member
  • *****
  • Posts: 738
Re: How to go first row and first colum in DBGrid?!?!
« Reply #3 on: August 11, 2017, 08:27:25 am »
TSQLQuery.first
Lazarus 1.64 (32b) / FPC 3.0
Windows 10

majid.ebru

  • Sr. Member
  • ****
  • Posts: 268
Re: How to go first row and first colum in DBGrid?!?!
« Reply #4 on: August 11, 2017, 10:37:36 am »
Hi
.
Did it work?
.
I think it is better to use:
with TCustomGrid(DBGrid1) do
.
.
.
Yes, it no work correctly , but it is better than DBGrid goes to last row and last colunm.
.
.
.
I think it is better to use:
with TCustomGrid(DBGrid1) do
.
.
.
the TCustomGrid does not have Row and Col ,but it has FRow and FCol and they are Private.!?!?
.
.
.
TSQLQuery.first
.
.
.
.
after i insert data , i use this code :
Code: Pascal  [Select]
  1. ZQuery_1.SQL.First
  2.  
but do not work?!?!
« Last Edit: August 11, 2017, 10:40:08 am by majid.ebru »

mangakissa

  • Hero Member
  • *****
  • Posts: 738
Re: How to go first row and first colum in DBGrid?!?!
« Reply #5 on: August 11, 2017, 01:09:37 pm »
read my post #3
Lazarus 1.64 (32b) / FPC 3.0
Windows 10

majid.ebru

  • Sr. Member
  • ****
  • Posts: 268
Re: How to go first row and first colum in DBGrid?!?!
« Reply #6 on: August 11, 2017, 02:42:20 pm »
read my post #3

OK
.
where i use your code? after insert?i use exactly write your code?my Zquery name is "ZQuery_1"?my code is wrong?

mangakissa

  • Hero Member
  • *****
  • Posts: 738
Re: How to go first row and first colum in DBGrid?!?!
« Reply #7 on: August 11, 2017, 03:56:16 pm »
Code: Pascal  [Select]
  1. begin
  2.   Zquery.post;
  3.   Zquery.first;
  4. end;
  5.  
Your info about saving is incomplete. There are a lot of ways to save data to your table.

Think that TDBgrid is a dummy component that give you focus to your records. All the things you do with data will be passed to your dataset with the help of TDatasource.
If you're using DBNavigator, put it in a OnClick event.
Lazarus 1.64 (32b) / FPC 3.0
Windows 10

majid.ebru

  • Sr. Member
  • ****
  • Posts: 268
Re: How to go first row and first colum in DBGrid?!?!
« Reply #8 on: August 17, 2017, 07:22:22 pm »
Code: Pascal  [Select]
  1. begin
  2.   Zquery.post;
  3.   Zquery.first;
  4. end;
  5.  
Your info about saving is incomplete. There are a lot of ways to save data to your table.

Think that TDBgrid is a dummy component that give you focus to your records. All the things you do with data will be passed to your dataset with the help of TDatasource.
If you're using DBNavigator, put it in a OnClick event.

Hi

it doesn't work ?!?!


taazz

  • Hero Member
  • *****
  • Posts: 4415
Re: How to go first row and first colum in DBGrid?!?!
« Reply #9 on: August 17, 2017, 08:38:22 pm »
Code: Pascal  [Select]
  1. begin
  2.   Zquery.post;
  3.   Zquery.first;
  4. end;
  5.  
Your info about saving is incomplete. There are a lot of ways to save data to your table.

Think that TDBgrid is a dummy component that give you focus to your records. All the things you do with data will be passed to your dataset with the help of TDatasource.
If you're using DBNavigator, put it in a OnClick event.

Hi

it doesn't work ?!?!
prove it. I say it works. post a sample that does not work.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus