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';
LVL 2
k6__Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.