Solved

double click event  to listview item

Posted on 2003-11-30
8
1,886 Views
Last Modified: 2010-04-05
how can I make double click event to listview item ?
0
Comment
Question by:sraab2004
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now