Hi all,
When I try to use the GetItemAt (e.X, e.Y) method in a ListView MouseDown()
event, it only works some of the time. If I right-click on an open area of
the ListView, I get null back as expected. If I right-click on a
ListViewItem, I get that ListViewItem back. But then... if I right-click on
an open area of the ListView again I get the last ListViewItem I clicked on
back... I'm sure there's a way around this. GetItemAt doesn't seem to be
holding onto the last value returned. I did something similar with the
TreeView GetNodeAt method, and it works as advertised. Anyone have any
ideas on this?
Thanks in advance,
Michael C. 2 11634
Michael,
I normally do this way, which is pretty accurate in retrieving items. You
can use this code, on mousehover, or mousemove, or mouse down event.
//use cursor points.
Point p = lstViewTest.PointToClient(new Point (Cursor.Position.X
,Cursor.Position.Y));
//now get the item.
ListViewItem pItem = lstViewTest.GetItemAt(p.X,p.Y )
Shak
"Michael C" <mi*******@optonline.net> wrote in message
news:4Q*********************@news4.srv.hcvlny.cv.n et... Hi all,
When I try to use the GetItemAt (e.X, e.Y) method in a ListView
MouseDown() event, it only works some of the time. If I right-click on an open area
of the ListView, I get null back as expected. If I right-click on a ListViewItem, I get that ListViewItem back. But then... if I right-click
on an open area of the ListView again I get the last ListViewItem I clicked
on back... I'm sure there's a way around this. GetItemAt doesn't seem to be holding onto the last value returned. I did something similar with the TreeView GetNodeAt method, and it works as advertised. Anyone have any ideas on this?
Thanks in advance, Michael C.
Thanks Shakir,
It looks like my bug was caused by a context menu I was using, but wasn't
clearing out between pop-ups. I used your code with the Clear() method of
the pop-up event for the context menu and it works great now!
Thanks,
Michael C.
"Shakir Hussain" <sh**@fakedomain.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... Michael,
I normally do this way, which is pretty accurate in retrieving items. You can use this code, on mousehover, or mousemove, or mouse down event.
//use cursor points. Point p = lstViewTest.PointToClient(new Point (Cursor.Position.X ,Cursor.Position.Y));
//now get the item. ListViewItem pItem = lstViewTest.GetItemAt(p.X,p.Y )
Shak "Michael C" <mi*******@optonline.net> wrote in message news:4Q*********************@news4.srv.hcvlny.cv.n et... Hi all,
When I try to use the GetItemAt (e.X, e.Y) method in a ListView MouseDown() event, it only works some of the time. If I right-click on an open area of the ListView, I get null back as expected. If I right-click on a ListViewItem, I get that ListViewItem back. But then... if I
right-click on an open area of the ListView again I get the last ListViewItem I clicked on back... I'm sure there's a way around this. GetItemAt doesn't seem to
be holding onto the last value returned. I did something similar with the TreeView GetNodeAt method, and it works as advertised. Anyone have any ideas on this?
Thanks in advance, Michael C.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Marco Auday |
last post by:
I need to associate items in two listviews. I have got the drag-and-drop operation to perform as I wanted. However, I would like the items in the target listview to be highlighted when the mouse...
|
by: Richard |
last post by:
Hi. I use a ListView to display data in tabular form.
Each ListView row corresponds to a data record.
The ListView Item of the record is the record key or code.
Each SubItem in that row...
|
by: Greg |
last post by:
I'm trying to display record information in labels, I've
got a listview filled with records and when you click on
one of them I want that record's information shown in
several labels. This is how...
|
by: Kovan A. |
last post by:
since i couldnt find anyway to scroll a listview having disabled the
scrollbars, i am left with no choice but to make the current scrollers
bigger
any leads as to which beast i am up against for...
|
by: Maheshkumar.R |
last post by:
hi groups,
I have placed an listview control, i want to iterate thru the control and find the clicked event items.
listView2.Items.Add(fname.ToString(), i);
how i can perform the iteration...
|
by: Dan |
last post by:
Hi. I want to be able to use the ListView::GetItemAt function from within
the ListView's DragDrop event callback. My problem is that GetItemAt
requires screen-space coordinates, and the...
|
by: Steve Long |
last post by:
I hope this isn't too stupid of a question but I'm looking for a way to
change an item in a listview control when the mouse moves over it. I'd like
to change its color and underline it for a...
|
by: Sim |
last post by:
Hello NG,
I try to use drag and drop function between two list views. For this I found
following code:
...
|
by: harry |
last post by:
Hi,
VS.2005 Pro / VB.NET
I find ListView.GetItemAt(x,y) always returns 'Nothing' when the returned
value would (if it worked) be a ListViewItem.
However, when the returned value is...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| | |