Solved

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

Posted on 2006-07-12
2
193 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 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

919 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now