Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2006-07-12
2
Medium Priority
?
200 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
[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
  • 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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 …
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.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
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…
Suggested Courses

722 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