Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How can i tell which column has been clicked in a listview?

Posted on 2006-07-12
2
Medium Priority
?
201 Views
Last Modified: 2010-04-23
I have an app with a ListView that is set to Details and has several columns. The ListView has a ContextMenu that I want users to be able to use to right click anywhere on the ListView and then select which way they would like the column they clicked on to be aligned. I am using the following code to align the columns:

lstvwColumns.Columns(3).TextAlign = HorizontalAlignment.Left

The problem I am having is how to get the above code to know which column to align depending on where on the ListView they user has clicked. I can find out which row but I don't know how to find out which column.
Can anyone help?
Thanks.
0
Comment
Question by:kiranboi
  • 2
2 Comments
 
LVL 8

Accepted Solution

by:
plq earned 1500 total points
ID: 17089175
This is the only way as far as I know

You would have to trap the mouse position in the mousedown event, store it in form level x,y variables, and refer to those variables in the itemclick event. You can add up the lvw.Left plus all the column widths until you exceed the x value, then you know you're on the right column.

BTW A better approach might be to use a right click popup menu which allows the user to align left, center, align right ?? But you'd still need to identify the column
0
 
LVL 8

Expert Comment

by:plq
ID: 17090768
B ?
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

886 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