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

Home Posts Topics Members FAQ

How to get the selected subitem in a item LISTVIEW

1 New Member
Hi

I have a LISTVIEW where every item have 6 subitems (columns).
Expand|Select|Wrap|Line Numbers
  1. lstBrowse.Columns.Add("Col1", 150, HorizontalAlignment.Left)
  2. lstBrowse.Columns.Add("Col2", 150, HorizontalAlignment.Left)
  3. lstBrowse.Columns.Add("Col3", 150, HorizontalAlignment.Left)
  4. lstBrowse.Columns.Add("Col4", 150, HorizontalAlignment.Left)
  5. lstBrowse.Columns.Add("Col5", 150, HorizontalAlignment.Left)
  6. lstBrowse.Columns.Add("Col6", 150, HorizontalAlignment.Left)
  7.  
I know how to get the selected item.
Expand|Select|Wrap|Line Numbers
  1. Dim SelectedOptions As ListView.SelectedListViewItemCollection = lstBrowse.SelectedItems
  2. Dim Item As ListViewItem = Me.lstBrowse.SelectedItems(0)
  3.  
But I need to give the opportunity to the end user, to select a subitem.

I want to know how to get the selected subitem because I will fire different procedures for every subitem clicked in a item.

I will appreciate if anybody can show me, how to do that...

Thanks in advance,
Mar 4 '09 #1
3 24985
smita acharya
1 New Member
Hi,

Even I have this problem.
Please reply if somebody has found the solution.

Regards,
Smita
Mar 10 '09 #2
X Enterprises
15 New Member
When the View property is set to "Details" you can't select a sub item because selecting an item selects the whole row.

I'm not sure about other view types.


You can, however, find the text value of a sub item.
Expand|Select|Wrap|Line Numbers
  1. Me.lstView1.SelectedItems(0).SubItems(1).Text
Mar 11 '09 #3
anreinor
4 New Member
I use this sequence of code:
It returns the row the user clicked in (as integer)
Further processing may be done in calling routine. In this case only a MsgBox is used now.
e.g.:

‘ within calling routine: (e.g. from the box-click-event, where parameters are sender and e)

Expand|Select|Wrap|Line Numbers
  1. Dim sel As ListViewItem = approofBox.GetItemAt(e.X, e.Y)
  2. MsgBox("row=" & getClickedRow(approofBox, e) & vbCrLf & " represents " & sel.SubItems(getClickedrow(approofBox, e)).Text & vbCrLf & sel.ToString)
... will show the clicked row, clicked item AND item in column(0)


' called routine:
Expand|Select|Wrap|Line Numbers
  1.  Function getClickedRow(ByVal box As System.Windows.Forms.ListView, ByVal e As System.Windows.Forms.MouseEventArgs) As Integer
  2.         Dim eex As Integer = 0
  3.         Dim appb As System.Windows.Forms.ColumnHeader
  4.         getClickedRow = -1
  5.         While (eex < e.X)
  6.             appb = box.Columns(getClickedRow + 1)
  7.             eex = eex + appb.width
  8.             getClickedRow = getClickedRow + 1
  9.         End While
  10.     End Function
Jun 18 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1286
by: Paddy | last post by:
I would like to do this: private void listView1_SelectedIndexChanged(etc) { // show the subitem of the item that was clicked } Please help. Paddy
4
50919
by: Steve Murphy | last post by:
Is there a way to set a selected index for a Listview in a WinForms application? Thanks in advance, Steve Murphy
0
3723
by: Webermax | last post by:
Hello, I want to retrieve the index of the selected item in a context menu synchronously. I coded something like this : MyContextMenu mcm; mcm = new MyContextMenu (); mcm.MenuItems.Add (new MenuItem ("hello")); mcm.MenuItems.Add (new MenuItem ("world")); mcm.Show ();
2
4876
by: baret bonden | last post by:
Trying to return a selected listbox item to another form .tried lots of ways; defining public variables and passing those as well as textboxes ..I' m able to display the chosen item on it's form in a textbox and I'm able to pass other variables to the 2nd form, but not the data I want . I should add this is a smartdeviceapplication(if that matters; not sure) Here's most of the test code .
3
8328
by: ljlevend2 | last post by:
I've noticed that selected items in a ListView are only highlighted if the control has focus. I find this to be highly undesirable because it can cause the control to behave differently than what would be expected based on the visual appearance. Is there any way to force the selected items to be highlighted even when the control does not have focus? Thanks, Lance
0
7539
by: Brian Henry | last post by:
Since no one else knew how to do this I sat here all morning experimenting with this and this is what I came up with... Its an example of how to get a list of items back from a virtual mode list view in .NET 2.0 with multiple selection turned on... since the .NET documentation is EXTREAML vague on how to do this and offers no clue on what the virtual mode events do or how to use them... just thought this might help someone else out...
0
1469
by: NeilS | last post by:
Hi all. I'm a newbie at VB.net, so please forgive me if this is well documented somewhere. I've found some sample code on the MS site for iterating over each unread item in the Inbox, and that's working and got me started well in automating Outlook 2003.
7
2030
by: Mike Johnson | last post by:
How do I remove a item that's been selected from a listview? I'm using Visual Basic 2005 express edition. Thanks
4
4458
by: Brett Wesoloski | last post by:
I am having a bit of a problem getting the current value of the checkbox list. I have tried using the selected value as I thought that would give me the current value of the check box but it appears to be giving me the first value that is selected all the time. I have also tried to use the selectedItem property but that does the same as I would expect becuase the property says it get the item with the lowest value.
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...
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...
1
6533
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
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
4627
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3057
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2345
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.