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
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
TRichMemo install shows "...
by
vinntec
[
Today
at 05:39:34 pm]
Perlin Map 3D
by
Dzandaa
[
Today
at 05:04:21 pm]
Anti "churning" in solita...
by
TBMan
[
Today
at 04:30:05 pm]
Lazarus for Windows on aa...
by
msintle
[
Today
at 03:11:13 pm]
would multi threading hel...
by
MathMan
[
Today
at 03:10:30 pm]
Perlin Noise Map With BGR...
by
Boleeman
[
Today
at 01:36:13 pm]
Strange Error when I use ...
by
Thaddy
[
Today
at 01:33:23 pm]
Strange Mail from memo.mi...
by
Thaddy
[
Today
at 01:27:19 pm]
[Solved] Lazreport. Sorti...
by
Petrus Vorster
[
Today
at 11:39:09 am]
Regarding the issue of de...
by
Martin_fr
[
Today
at 11:16:29 am]
[Windows] UTF8 encoding w...
by
Thaddy
[
Today
at 10:42:15 am]
Pleas help, Synapse / Ind...
by
patyit
[
Today
at 10:25:29 am]
Default, Manual Initializ...
by
Okoba
[
Today
at 09:17:22 am]
How to observe the value ...
by
yinhuajian
[
Today
at 05:50:14 am]
Cannot see unit text - ed...
by
lorenzo
[
Today
at 04:05:13 am]
AdvancedHTTPServer: A Go-...
by
egsuh
[
Today
at 01:44:33 am]
What's wrong with my appl...
by
VisualLab
[
Today
at 01:04:16 am]
ThemeServices.OnThemeChan...
by
440bx
[
Today
at 12:16:35 am]
Cross Compile for Dos on ...
by
PascalDragon
[January 20, 2026, 10:54:36 pm]
Feature announcement: Fun...
by
PascalDragon
[January 20, 2026, 09:50:39 pm]
Access violation during d...
by
PascalDragon
[January 20, 2026, 09:49:09 pm]
IStringList...
by
PascalDragon
[January 20, 2026, 09:35:54 pm]
Strings in Free Pascal: I...
by
PascalDragon
[January 20, 2026, 09:33:09 pm]
Developing FreePascal on ...
by
HKPhysicist
[January 20, 2026, 08:59:53 pm]
[Solved] Exception in TFi...
by
d.oertel
[January 20, 2026, 06:18:05 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: How to get Current row number of a DBGrid within a filtered Query? (Read 11580 times)
JSN
Jr. Member
Posts: 65
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