• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 371
  • Last Modified:

Detecting Selected Rows In DBGrid ?

Hello.. i have a DBGrid with a couple
of records and multiselect = true.
How can i update eg a label with the
count of Selected Rows ?

Eg user click 2 items on DBGrid so the
DBGrid Will update -> MyLabel.Caption := '2';
0
k6__
Asked:
k6__
  • 2
  • 2
1 Solution
 
intheCommented:
hi k6

you can do:

procedure TForm1.DBGrid1CellClick(Column: TColumn);
begin
label1.caption := 'you have selected '+inttostr(dbgrid1.SelectedRows.Count);
end;

Regards Barry
0
 
k6__Author Commented:
Hmm.. i must be very stupid =) eheh.. how can i miss this property.. anyway thanx.. btw.. after selecting one item and then scrolling eg down the grid it doesn't deselects the first item and a second highlighted item remains. (the weird is the SelectedRows.Count Value = 1!) .... do you know how to solve it ?

Thanx a lot for your help
0
 
k6__Author Commented:
a typo:
second highlighted item remains
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
it creates a second highlight .. = 2 blue bars (RowSelect = True)

Also sorry about the duplicates... i think i hitted only once...
0
 
intheCommented:
no i tried this myself its like it doesnt do it until unselected again.strange,i think meikl(kretzschmar) did a component for similar to this for another question where had problem with deselecting.it will be near top of his paq if you want to risk the points to see if it helps.
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now