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

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

-Good luck!!
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.
karen021897Author Commented:
yes Madsi, can you have any example of that?
Upgrade your Question Security!

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

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);
  caption := 'this item changed: ' + Item.caption;

Does this help?

Regards, Madshi.
karen021897Author Commented:

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?
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
    else ListBox1.Items.Delete(ListBox1.Items.IndexOf(Item.Caption));

Regards, Madshi.

P.S: I didn't test that, but it should work like this...

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!!!

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

From novice to tech pro — start learning today.