Solved

double click event  to listview item

Posted on 2003-11-30
8
2,141 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
Technology Partners: 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

728 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