Solved

Selecting Subitems by Click - VB.Net

Posted on 2007-11-26
5
3,417 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

737 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