[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

double click event  to listview item

Posted on 2003-11-30
8
Medium Priority
?
2,342 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 100 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 100 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
Independent Software Vendors: 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 100 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 100 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

649 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