Solved

Selecting Subitems by Click - VB.Net

Posted on 2007-11-26
5
3,420 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

734 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