Solved

double click event  to listview item

Posted on 2003-11-30
8
1,974 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

777 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