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

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?
0
karen021897
Asked:
karen021897
  • 3
  • 3
1 Solution
 
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
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
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
 
karen021897Author Commented:
You are the best!!!

Thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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