Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get a DataGrid column's index in a MouseUp event, not a MouseDown ()

Status
Not open for further replies.

clem06

Programmer
Mar 5, 2004
3
GB
Hello all,
I have a winform with two DataGrid, my goal is to drag a column's name of the first DataGrid and drop it in a cell of the second DataGrid. To do that I use HitTestInfo:

System.Windows.Forms.DataGrid.HitTestInfo myHitTest;
myHitTest = dataGrid1.HitTest(e.X,e.Y);
int p=myHitTest.Column;

When I click on the first datagrid, this code run and give me the column's index (p), the problem is when I drop it in the second DataGrid, I'd like to know the target column's index. With the same code p=-1, I think because the HitTestInfo member return a value on a MouseDown and not on a MouseUp. If anyone can tell me how to do it, it would be very great

P.S: I saw the FAQ solution "How can I get text from a column header in a MouseUp event" .
but it doesn't run, so tell me if I have to try again with this code.
Thanks for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top