Solved

Selecting Subitems by Click - VB.Net

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

615 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