Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
ow to check which subitem of a TListView's ListItem was clicked (2) Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
31-Oct-02
Category
VCL-General
Language
Delphi 2.x
Views
108
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

Is it possible to activate the click or double-click event for the subitems of a 
listview item? If yes, how can I do it?

Answer:

1   uses
2     CommCtrl;
3   
4   {$R *.dfm}
5   
6   procedure TForm1.ListView1Click(Sender: TObject);
7   var
8     pt: TPoint;
9     item: TLIstItem;
10    hittestinfo: TLVHitTestInfo;
11  begin
12    pt := listview1.ScreenToClient(mouse.cursorpos);
13    item := listview1.GetItemAt(pt.x, pt.y);
14    if assigned(item) then
15      memo1.Lines.add('Hit on item ' + item.Caption)
16    else
17    begin
18      FillChar(hittestinfo, sizeof(hittestinfo), 0);
19      hittestinfo.pt := pt;
20      if - 1 <> listview1.perform(LVM_SUBITEMHITTEST, 0, lparam(@hittestinfo)) then
21      begin
22        memo1.lines.add(format('Item: %d (%s), subitem: %d (%s)', [hittestinfo.iItem,
23          listview1.items[hittestinfo.iItem].caption, hittestinfo.iSubItem,
24            listview1.items[hittestinfo.iItem].Subitems[hittestinfo.iSubItem - 1]]));
25  
26      end
27      else
28        memo1.lines.add('Not on item or subitem');
29    end;
30  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC