Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
LCL
»
How to get Current row number of a DBGrid within a filtered Query?
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
WIKI Timeout issues
Please read here if you have trouble connecting to the wiki
Recent
How to toggle back to the...
by
munair
[
Today
at 08:59:54 am]
[SOLVED] Which RTL Unit d...
by
Thaddy
[
Today
at 08:34:58 am]
OpenDialog and mouse even...
by
hedgehog
[
Today
at 08:06:03 am]
Lazarus 4, What's wrong w...
by
incendio
[
Today
at 07:59:48 am]
Strict Aliasing Rule
by
Thaddy
[
Today
at 07:02:16 am]
IBX 2.7.2.1650 Bug?
by
incendio
[
Today
at 06:33:52 am]
Where to download IBX pre...
by
incendio
[
Today
at 06:17:46 am]
IBX, unable to install pr...
by
incendio
[
Today
at 04:34:20 am]
Component to manage short...
by
EganSolo
[
Today
at 12:36:36 am]
Replace controls dynamica...
by
Aruna
[June 18, 2025, 11:58:42 pm]
CEF component - the first...
by
wp
[June 18, 2025, 08:21:11 pm]
slim installation by remo...
by
wp
[June 18, 2025, 08:19:09 pm]
Crash on changing a strin...
by
Martin_fr
[June 18, 2025, 08:11:34 pm]
How to stop macro executi...
by
Martin_fr
[June 18, 2025, 08:06:44 pm]
Layout problem by nested ...
by
etrusco
[June 18, 2025, 07:55:44 pm]
Build failure
by
user5
[June 18, 2025, 07:42:34 pm]
Loading an image from an ...
by
Fred vS
[June 18, 2025, 06:29:01 pm]
IDE Lazarus 4.0 on Window...
by
Martin_fr
[June 18, 2025, 03:47:30 pm]
Lazarus 4.0 RC3
by
paxnet_be
[June 18, 2025, 02:34:23 pm]
Firebird 5 remote login v...
by
LacaK
[June 18, 2025, 02:07:34 pm]
Compile errors in MacBook...
by
Thaddy
[June 18, 2025, 11:46:06 am]
LAMW - UTF-8 character in...
by
Alcatiz
[June 18, 2025, 11:36:29 am]
How to run an external pr...
by
vsajip
[June 18, 2025, 08:50:34 am]
lazbuild command line swi...
by
n7800
[June 18, 2025, 04:21:35 am]
dBGRidController and Erro...
by
essence-ciel
[June 18, 2025, 01:15:11 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: How to get Current row number of a DBGrid within a filtered Query? (Read 11203 times)
JSN
Jr. Member
Posts: 60
How to get Current row number of a DBGrid within a filtered Query?
«
on:
June 01, 2017, 01:56:56 pm »
I have found other solutions to obtaining the current selected row number of a DBGrid. But those seem to return the Record Number of the dataset.
If a Query is filtered, how do I obtain the current selected row number of the DBGrid?
Hope this makes sense.
Logged
taazz
Hero Member
Posts: 5368
Re: How to get Current row number of a DBGrid within a filtered Query?
«
Reply #1 on:
June 01, 2017, 02:58:24 pm »
you ask the dataset eg
Code:
[Select]
showmessage(inttostr(DBGrid1.DataSource.DataSet.RecNo));
oops to hasty didn't read the question through. sorry but this one I'll have to answer it after work.
«
Last Edit: June 01, 2017, 02:59:55 pm by taazz
»
Logged
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
balazsszekely
Guest
Re: How to get Current row number of a DBGrid within a filtered Query?
«
Reply #2 on:
June 01, 2017, 03:58:13 pm »
@JSN
Ideally you should write a class helper or modify DBGrids.pas and publish a new property. Anyway I found a way, all you have to do is replace "Name" with the field you wish to see(I assume multiselect is off, and your form name is Form1):
Code: Pascal
[Select]
[+]
[-]
procedure
TfMain
.
DBGridDrawColumnCell
(
Sender
:
TObject
;
const
Rect
:
TRect
;
DataCol
:
Integer
;
Column
:
TColumn
;
State
:
TGridDrawState
)
;
var
Row
:
Integer
;
begin
if
gdSelected
in
State
then
begin
Row
:
=
Trunc
(
Rect
.
Bottom
/
(
Sender as TDBGrid
)
.
DefaultRowHeight
)
-
1
;
Form1
.
Caption
:
=
DBGrid
.
DataSource
.
DataSet
.
FieldByName
(
'NAME'
)
.
AsString
+
' '
+
IntToStr
(
Row
)
;
end
;
end
;
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
LCL
»
How to get Current row number of a DBGrid within a filtered Query?
TinyPortal
© 2005-2018