Solved

double click event  to listview item

Posted on 2003-11-30
8
2,058 Views
Last Modified: 2010-04-05
how can I make double click event to listview item ?
0
Comment
Question by:sraab2004
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 5

Accepted Solution

by:
Darth_helge earned 25 total points
ID: 9844914
yes you can.
this example has three items in a listview:

procedure TForm1.ListView1DblClick(Sender: TObject);
var
  Valgt : integer;
begin
if ListView1.Selected <> nil then
  begin
  case ListView1.Selected.Index of
    0: DoSomethingWithItem1;
    1: DoSomethingWithItem2;
    2: DoSomethingWithItem3;
  end;
  end;
end;
0
 
LVL 2

Assisted Solution

by:monir
monir earned 25 total points
ID: 9844921

HI,

Use DblClick event then search for the selected items like this:

procedure TFrm_S_Main.MI_SendMessageClick(Sender: TObject);
var index: integer;
    ListItem: TListItem;
begin
  for index:=0 to LV_UsersView.Items.Count-1 do begin
    ListItem:= LV_UsersView.Items[index];
    if ListItem.Selected then begin
      // do whatever you want
      end;
  end;

Hope that help.

Monir
0
 
LVL 5

Expert Comment

by:Darth_helge
ID: 9844926
mine is a lot easier, though
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:Darth_helge
ID: 9844931
to actually get the double click event on the listview, you have to select the listview, click on the event-tab in the object inspector (push F11) if it is not visible on the screen. then search your way down to the event "OnDblClick". Just double-click in the field here, and delphi will create an empty double-click event on the listview for you like this:

procedure TForm1.ListView1DblClick(Sender: TObject);
begin
end;

then you can fill in with my code
(only if you have three items, thoug. if you have e.g two items , remove the last case sentence)
0
 
LVL 1

Assisted Solution

by:roknjohn
roknjohn earned 25 total points
ID: 9846536
If you aren't using the MultiSelect mode, you can just use the TlistView.Selected property to identify the selected item in the list.

procedure TForm1.DoSomething(ListItem : TListItem);
begin
  //Do your thing here
end;

procedure TForm1.ListView1DblClick(Sender: TObject);
begin
  with Sender as TListView do
    if Selected<>nil then
      DoSomething(Selected);
end;
0
 
LVL 5

Assisted Solution

by:Hypoviax
Hypoviax earned 25 total points
ID: 9854238
If you want to physically (even though it is a program) doubleclick you can use mouse events:

1. Specify a point
2. Setcursor(point.x,point.y)
3.mouse_event(lmouse_down,0,0,0,0); //Press F1 to make sure my syntax is correct as i think it is wrong. You want the left
   mouse_event(lmouse_up,0,0,0,0)                                                         mouse down and the left mouse up to do one click
   mouse_event(lmouse_down,0,0,0,0); //Do again for a double click
   mouse_event(lmouse_up,0,0,0,0);

Probably not what you are looking for but anyway try it.

Regards,

Hypoviax
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question