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
WIKI Timeout issues
Please read here if you have trouble connecting to the wiki
Recent
[SOLVED] Can't compile my...
by
the_magik_mushroom
[
Today
at 06:58:15 am]
How do you change a packa...
by
Aruna
[
Today
at 05:56:19 am]
Fast Canvas Library V1.05...
by
Gigatron
[
Today
at 02:39:11 am]
GitHub action setup-lazar...
by
Gustavo 'Gus' Carreno
[
Today
at 01:58:23 am]
Problems with libraries f...
by
regs
[
Today
at 12:25:55 am]
Build Lazarus with packag...
by
msch
[
Today
at 12:21:34 am]
Playing video without to ...
by
n7800
[July 19, 2025, 11:40:42 pm]
RuntimeError 103 File not...
by
marcov
[July 19, 2025, 09:32:22 pm]
LazGTFS a freepascal/Laza...
by
EkkehardDomning
[July 19, 2025, 09:03:43 pm]
Can't register Lazmapview...
by
Dzandaa
[July 19, 2025, 06:05:34 pm]
Bzzzz It's Cold here: An...
by
Joanna
[July 19, 2025, 06:01:40 pm]
[solved] can't close app ...
by
Thaddy
[July 19, 2025, 05:26:40 pm]
[Solved] OpenGLContext wi...
by
aydın
[July 19, 2025, 03:27:14 pm]
AI, NLP and CAI: Text Gen...
by
Mongkey
[July 19, 2025, 01:59:33 pm]
[SOVED] Debugger use on O...
by
440bx
[July 19, 2025, 01:19:47 pm]
Not happy with TTimeEdit
by
JuhaManninen
[July 19, 2025, 01:07:54 pm]
Debugger regression in La...
by
Martin_fr
[July 19, 2025, 09:29:04 am]
[SOLVED] UTF8 Keyboard en...
by
Richard Marriott
[July 19, 2025, 07:05:39 am]
Possible Bug or Known Beh...
by
Aruna
[July 19, 2025, 05:26:47 am]
tSQLQuery.UpdateSQL with ...
by
JRBleau
[July 19, 2025, 04:21:39 am]
Default Component Size mi...
by
SandyG
[July 19, 2025, 04:13:20 am]
Has anyone installed TeeB...
by
wp
[July 19, 2025, 12:54:14 am]
Sharing utilities
by
lucabertoncini
[July 19, 2025, 12:43:02 am]
project - count source li...
by
wp
[July 19, 2025, 12:26:10 am]
As anyone proposed the fo...
by
Gustavo 'Gus' Carreno
[July 19, 2025, 12:18:36 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: How to get Current row number of a DBGrid within a filtered Query? (Read 11271 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