Listview - questions


Questions about listview

how can i , when user press item with checkbox and he check that item. How can
i get the handle of the string or value or something or the integer index?
karen021897Asked:
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.

DrDelphiCommented:
If you are asking how to determine the index within the Listview, look at the Listview.Selected.Index



-Good luck!!
0
MadshiCommented:
Well, what if the Listview is in MultiSelect mode? I think it would better to use ListView.ItemFocused.Index. I'm not sure, perhaps you can use the "OnChange" event. There you get an TListItem item as a parameter. Then you can ask item.index or item.Checked.

Regards, Madshi.
0
karen021897Author Commented:
yes Madsi, can you have any example of that?
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

MadshiCommented:
Double click on the "OnChange" event in the object inspector, then add this code to the event handler:

procedure TForm1.ListView1Change(Sender: TObject; Item: TListItem; Change: TItemChange);
begin
  caption := 'this item changed: ' + Item.caption;
end;

Does this help?

Regards, Madshi.
0
karen021897Author Commented:
ok!!!

lets say if i have one listview and one listbox, if i have 10 items in listview with checkbox and i check any of the items i will be able to add them to listbox and if i uncheck in listview the i will delete the text in listbox. Is this possible?
0
MadshiCommented:
Of course!

In the ListView1Change event you can do something like this:

  if Item.Checked <> (ListBox1.Items.IndexOf(Item.Caption) <> -1) then
    if Item.Checked then
         ListBox1.Items.Add(Item.Caption)
    else ListBox1.Items.Delete(ListBox1.Items.IndexOf(Item.Caption));

Regards, Madshi.

P.S: I didn't test that, but it should work like this...
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
karen021897Author Commented:
You are the best!!!

Thanks
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.