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
Benchmark test in nanosec...
by
valdir.marcos
[
Today
at 03:27:08 pm]
Debian removes FPC/Lazaru...
by
zeljko
[
Today
at 02:52:21 pm]
Problem wih reference to ...
by
henrique
[
Today
at 02:39:50 pm]
How many lines is too man...
by
Martin_fr
[
Today
at 02:14:49 pm]
uses unit decalration ord...
by
Martin_fr
[
Today
at 02:10:32 pm]
Update a table with an Au...
by
CraigC
[
Today
at 01:56:50 pm]
could Ardour's YTK be use...
by
robert rozee
[
Today
at 01:51:39 pm]
[SOLVED] File Format LAMW...
by
RaketeMike
[
Today
at 01:41:46 pm]
[ANN] PasBuild 1.5.0 rele...
by
cdbc
[
Today
at 05:10:09 am]
Commerce website written ...
by
valdir.marcos
[
Today
at 04:55:08 am]
New book on Object Pascal
by
valdir.marcos
[
Today
at 04:30:08 am]
How to execute a procedur...
by
Aruna
[
Today
at 03:34:41 am]
BGRAVirtualScreen - weird...
by
backprop
[
Today
at 03:33:51 am]
The "dockedformeditor" pa...
by
Gustavo 'Gus' Carreno
[
Today
at 02:44:31 am]
unit ProjectDescriptorTyp...
by
n7800
[
Today
at 02:01:39 am]
TDirectoryEdit with OnAft...
by
dsiders
[
Today
at 12:20:23 am]
Canvas.StretchDraw, does ...
by
jamie
[March 06, 2026, 11:27:18 pm]
Front-end framework
by
kveroneau
[March 06, 2026, 08:00:37 pm]
REST Server/Client, how t...
by
kveroneau
[March 06, 2026, 07:35:25 pm]
Variable initialization
by
LeP
[March 06, 2026, 06:58:53 pm]
[SOLVED] Problem to resto...
by
Hartmut
[March 06, 2026, 06:42:28 pm]
Text Fill (Memo)
by
Sc0li0sis
[March 06, 2026, 06:08:54 pm]
BGRA Controls license inf...
by
Zoran
[March 06, 2026, 05:48:27 pm]
TCalendar Assign a Date
by
eldonfsr
[March 06, 2026, 05:04:10 pm]
[Feature Request]Add Larg...
by
TYDQ
[March 06, 2026, 03:03:31 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: How to get Current row number of a DBGrid within a filtered Query? (Read 11684 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