473,699 Members | 2,680 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Any better way to find the Clicked SubItem in a ListView ?



Any way to find the Clicked SubItem in a ListView ?

private int GetSubItemAtPos (ListView AListView, Point APoint)
{
int PositionCounter = 0;
int TmpRelativeColI ndex = -1;
//Browse All Column by DISPLAYED INDEX
for (int ColDisplayCount = 0; ColDisplayCount < AListView.Colum ns.Count;
ColDisplayCount ++)
{
//Find ColumnIndex relative to the current ColDisplayCount
TmpRelativeColI ndex = -1;
for (int ColIndexCount = 0; ColIndexCount < AListView.Colum ns.Count;
ColIndexCount++ )
{
if (AListView.Colu mns[ColIndexCount].DisplayIndex ==
ColDisplayCount )
{
TmpRelativeColI ndex = ColIndexCount;
break;
}
}
//if a TmpRelativeColI ndex has been found, check if X pos is now
inside new bounds
if (TmpRelativeCol Index > -1)
{
//Incremental end position
PositionCounter +=
AListView.Colum ns[TmpRelativeColI ndex].Width;
//chec if X pos is inside bounds
if (APoint.X < PositionCounter ) return TmpRelativeColI ndex;
}
}
return -1;
}

steph.
May 17 '06 #1
1 2162
int i = 0;

foreach(ListVie wItem myView in this.lvBody.Ite ms)
{
if(this.lvBody. Items[i].Selected == true)
{
DoSomething;
}
}
But you can interchange lvBody with myView with the syntax
myView.ListView Item and treat it as normal

Hope that helps a bit

MikeY
"TheSteph" <Th******@NoSpa m.com> wrote in message
news:uw******** ******@TK2MSFTN GP03.phx.gbl...


Any way to find the Clicked SubItem in a ListView ?

private int GetSubItemAtPos (ListView AListView, Point APoint)
{
int PositionCounter = 0;
int TmpRelativeColI ndex = -1;
//Browse All Column by DISPLAYED INDEX
for (int ColDisplayCount = 0; ColDisplayCount < AListView.Colum ns.Count;
ColDisplayCount ++)
{
//Find ColumnIndex relative to the current ColDisplayCount
TmpRelativeColI ndex = -1;
for (int ColIndexCount = 0; ColIndexCount <
AListView.Colum ns.Count;
ColIndexCount++ )
{
if (AListView.Colu mns[ColIndexCount].DisplayIndex ==
ColDisplayCount )
{
TmpRelativeColI ndex = ColIndexCount;
break;
}
}
//if a TmpRelativeColI ndex has been found, check if X pos is now
inside new bounds
if (TmpRelativeCol Index > -1)
{
//Incremental end position
PositionCounter +=
AListView.Colum ns[TmpRelativeColI ndex].Width;
//chec if X pos is inside bounds
if (APoint.X < PositionCounter ) return TmpRelativeColI ndex;
}
}
return -1;
}

steph.

May 17 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3114
by: Angel Monson | last post by:
Is there a way I can find out which item I double-clicked inside a listview? And what about with subitems? And once I get an item number, can I use it to read the item and subitem contents? And if I click on one item, what do I need to do in order for me to highlight that item I clicked in the following X items? Since I'll be displaying addressses in the listbox, I'd like to be able to highlight the whole address when the user clicks on...
1
23695
by: andrewcw | last post by:
The clcik event on the ListView control seems to trigger off the item level ( the first column ). I would like to be able to trap the click event on a particular subitem ( a specific column's row ). If possible, what do I do to activate that 'cell' - thanks. I thought that listView.LabelEdit = true; would enable me to navigate into the cells or something like listView.items .subitems.LabelEdit - but I did not see such a property....
2
19273
by: Peter Steele | last post by:
I have a form containing a ListView with four columns, creating a multi-cell table. I want to have an event which can determine which cell in the table is under the cursor when a double-click is done. The double-click event of the ListView double-click event handler only passes in the sender object and the EventArgs object. How can I figure out the specific cell where the click occurred? Peter Steele CIENA Corp.
2
4460
by: Paddy | last post by:
private void listView1_SelectedIndexChanged(object sender, System.EventArgs e) { textBox1.Text = this.listView1.Items.SubItems.Text; } This will display sub item after cklicking on item I want to display subitem of any item I click on how do I do that? Many thanks.
2
6660
by: Max Adams | last post by:
ListView - changing the text of subitem n? All, How can I change the text of a specific subitem of a specific ListViewItem? I want to have some "Status" column which I want to continually update based on the progress of the program. Thanks PT
0
1434
by: Popoxinhxan | last post by:
Hi guy , i would like to have a Find search function like in Ms Excel to search for specific keyword in the list view. Could anyone help me to do so. Currently i can only get the index of the item in the list view but i don't know how to make the findnext function work, i.e. return the index of the list view item then if the findNext invoke again, the next index of list view will be returned until there is no more match. Here is the code ...
6
6846
by: Jano | last post by:
Hello. I have one question I make Listview with 4 columns. And I want add text to to column 2,3,4. With listview1->Items->add ("Text") I can add text only to first column. In Visual basic.NEt I can write listview1.Items(x).Subitem(number column).Add ("Text"). Is something like this in VC.NET? Thanks for answers.
2
1561
by: H.B. | last post by:
Hi, How can I get the SubItem clicked in a ListView in detail mode. Thanks, Hugo
1
6411
by: James | last post by:
Hi All, I have an ownerdraw ListView control. I'm trying to use an ownerdrawn ListView control to draw and display images in the second column of a listview which is set to detail view. I have overridden the DrawColumnHeader, DrawItem, DrawSubItem methods as displayed below. It is drawing the icon correctly, however, when I click on a row, the middle column, eg. column 1 is not being shown as selected. All other columns look selected...
0
8686
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8615
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9173
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8911
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7748
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5872
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4375
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4627
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2009
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.