By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,853 Members | 1,003 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,853 IT Pros & Developers. It's quick & easy.

Drag and Drop into a DataGrid

P: n/a
Hello:

I have spent two days on drag and drop now and I'm getting no where.
I am trying to drag an item from a listbox and load it into a datagrid
(actually a child of the datagrid, but I'll be happy for now to get to
the parent.) I can get the selected row of the target, but that is
not the same as dropped_on row. I've tried to get the mouse_up
event, but drag and drop seems to override the mouse_up. I've tried
the hitTest but it seems also not to be activated in the drop event.

If I can get the row index, I think I can get the values I need.

Thanks,

Ken
Nov 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi,
[Inline]

"Ken Loomis" <no*************@nodomain.com> wrote in message
news:h2********************************@4ax.com...
Hello:

I have spent two days on drag and drop now and I'm getting no where.
I am trying to drag an item from a listbox and load it into a datagrid
(actually a child of the datagrid, but I'll be happy for now to get to
the parent.) I can get the selected row of the target, but that is
not the same as dropped_on row. I've tried to get the mouse_up
event, but drag and drop seems to override the mouse_up. I've tried
the hitTest but it seems also not to be activated in the drop event.

If I can get the row index, I think I can get the values I need.
It should work with HitTest, did you try something like:

private void dataGrid1_DragDrop(object sender,
System.Windows.Forms.DragEventArgs e)
{
DataGrid.HitTestInfo ht = dataGrid1.HitTest(
dataGrid1.PointToClient( new Point( e.X, e.Y ) ) );

Console.WriteLine( ht.Row );
Console.WriteLine( ht.Column );
Console.WriteLine( ht.Type );
}

HTH,
Greetings


Thanks,

Ken

Nov 17 '05 #2

P: n/a
On Thu, 28 Jul 2005 14:50:32 +0200, "Bart Mermuys"
<bm*************@hotmail.com> wrote:
I am trying to drag an item from a listbox and load it into a datagrid
I've tried
the hitTest but it seems not to be activated in the drop event.


It should work with HitTest, did you try something like:

private void dataGrid1_DragDrop(object sender,
System.Windows.Forms.DragEventArgs e)
{
DataGrid.HitTestInfo ht = dataGrid1.HitTest(
dataGrid1.PointToClient( new Point( e.X, e.Y ) ) );


Bart:
I had: dataGrid1.HitTest(e.X,e.Y).

I didn't know about PointToClient.

I guess the relevant information from the Help is:
"Because the DragEventArgs.X and DragEventArgs.Y values are screen
coordinates, the example uses the PointToClient method to convert them
to client coordinates."

Thanks very much.

Ken

Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.