472,354 Members | 2,231 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,354 software developers and data experts.

How to get the selected subitem in a item LISTVIEW

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 24282
Hi,

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

Regards,
Smita
Mar 10 '09 #2
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
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
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
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
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...
2
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...
3
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...
0
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...
0
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...
7
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
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...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...

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.