Solved

Selecting Subitems by Click - VB.Net

Posted on 2007-11-26
5
3,415 Views
Last Modified: 2013-11-26
Hi All,

I need to select a listviewitem subitem by clicking/double-clicking on it.

I have a listview with a number of columns in it, and I need to be able to perform a function etc by clicking a subitem.

I like the layout options that the listview gives e.g. Groups, Tiles or I would have used a grid control.

Thanks
0
Comment
Question by:nzfire
  • 3
  • 2
5 Comments
 
LVL 48

Accepted Solution

by:
jpaulino earned 500 total points
ID: 20354087
You can do this to check what column/subitem was clicked. It just have to adapt it to your needs.

        Dim colstart As Integer = 0
        Dim colend As Integer = 0
        Dim x As Integer

        For x = 0 To (ListView1.Columns.Count - 1)
            colend = colend + ListView1.Columns(x).Width
            If colstart <= e.X And e.X <= colend Then
                Label1.Text = "Column clicked: " & x + 1
                Exit For
            End If
            colstart = colstart + ListView1.Columns(x).Width
        Next
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 20354097
But why don't you use a datagridview ?
0
 
LVL 1

Author Comment

by:nzfire
ID: 20354174
Hi jpaulino,

Thanks for the reply. As I mentioned in the Q, I like the layour that the listview gives in terms of creating groups etc. I don't know if this is possible in the datagridview.......

In your reply, how would I determine the item property though...i.e. the selected item?
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 20354251
Thats more difficult to calculate!

If set the listview fullrowselect = true when you right click on the item will select him.
0
 
LVL 1

Author Comment

by:nzfire
ID: 20354277
Ok, this sounds more difficult than I thought.

I didn't want to do a full row select as I am displaying different backcolours for the subitems...maybe I will just have to live with the fact that I can't LOL!!!

I'll leave this q up to see if there is any more response
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

821 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