Click here to Skip to main content
15,914,370 members
Home / Discussions / C#
   

C#

 
AnswerRe: Undo and Redo in Drawing Editor Pin
mav.northwind28-May-07 19:16
mav.northwind28-May-07 19:16 
AnswerRe: DXF reading and drawing with undo and redo functions in Drawing Editor Pin
mav.northwind28-May-07 19:20
mav.northwind28-May-07 19:20 
Questionsorting grid view Pin
tauras8128-May-07 18:00
tauras8128-May-07 18:00 
AnswerRe: sorting grid view Pin
Sathesh Sakthivel28-May-07 18:05
Sathesh Sakthivel28-May-07 18:05 
QuestionHelp me, please Pin
angelinajoilie28-May-07 17:25
angelinajoilie28-May-07 17:25 
AnswerRe: Help me, please Pin
Sathesh Sakthivel28-May-07 17:58
Sathesh Sakthivel28-May-07 17:58 
QuestionLinux client with Windows Server Pin
islheg28-May-07 9:35
islheg28-May-07 9:35 
QuestionWhat am I missing here??? [modified] Pin
new_phoenix28-May-07 7:55
new_phoenix28-May-07 7:55 
I am working on an application that implements a drag and drop interface, but when I drag the control with the mouse the control's position does not actually change until the cursor touches the form. That is, if I have a control that is 200 pixels tall by 150 pixels wide and I click the cursor and hold it at pixel 100 and 50, the control does not move until the cursor touches the form, but then the cursor is again positioned at the drag point again. This causes the control to move in jumps. I would like the cursor to remain at the drag position where the cursor was clicked and to drag from that point smoothly without the cursor needing to touch the form.

Do I need to somehow resample the control's position so that it moves using the drag point without needing to touch the form?

Here is the code

private static void _ctrlParent_DragOver(object sender, DragEventArgs e)
{
	try
	{
		if (DragDropHandler.CanDropHere((Control)sender, e.Data))
		{
			Control cthis = (Control)sender;
			Control cthisParent = ((Control)sender);

			e.Effect = DragDropEffects.Move;
			Control ctrl = DragDropHandler.GetControl(e.Data, true, true);
				
			if (!(ctrl is IDragDropEnabled))
			{
				return;
			}
			if (cthis.Name != ctrl.Name)
			{
				ctrl.Parent.Controls.Remove(ctrl);
				ctrl.Parent = cthis;
				cthis.Controls.Add(ctrl);
				ctrl.BringToFront();
			}
			else
			{
				return;
			}
			Point NewLocation = cthis.PointToClient(new Point(e.X, e.Y));
			ctrl.Left = NewLocation.X - dragPoint.X;
			ctrl.Top = NewLocation.Y - dragPoint.Y;  // Do I need to resample the control's position here?
		}
		else
		{
			e.Effect = DragDropEffects.None;
		}
	}
	catch (System.Exception ex)
	{
		MessageBox.Show("Error is " + ex.GetBaseException());
	}
}




-- modified at 14:26 Monday 28th May, 2007
AnswerRe: What am I missing here??? Pin
Guffa28-May-07 8:37
Guffa28-May-07 8:37 
GeneralRe: What am I missing here??? Pin
new_phoenix2-Jun-07 12:19
new_phoenix2-Jun-07 12:19 
AnswerRe: What am I missing here??? Pin
Guffa2-Jun-07 14:03
Guffa2-Jun-07 14:03 
Questioni have to ask regarding "Report Parameter" Pin
Lucky Hamad28-May-07 7:23
Lucky Hamad28-May-07 7:23 
QuestionRegular Expressions... Pin
simplicitylabs28-May-07 5:55
simplicitylabs28-May-07 5:55 
AnswerRe: Regular Expressions... Pin
J. Dunlap28-May-07 6:28
J. Dunlap28-May-07 6:28 
GeneralRe: Regular Expressions... Pin
simplicitylabs28-May-07 6:48
simplicitylabs28-May-07 6:48 
GeneralRe: Regular Expressions... Pin
J. Dunlap28-May-07 7:16
J. Dunlap28-May-07 7:16 
QuestionRe-Starting an application after self killing (autodestruction) Pin
dannygilbert328-May-07 5:24
dannygilbert328-May-07 5:24 
AnswerRe: Re-Starting an application after self killing (autodestruction) Pin
Dave Herren28-May-07 5:38
Dave Herren28-May-07 5:38 
AnswerRe: Re-Starting an application after self killing (autodestruction) Pin
Giorgi Dalakishvili28-May-07 7:15
mentorGiorgi Dalakishvili28-May-07 7:15 
QuestionSecurity report icons on IE Pin
ilaxi28-May-07 4:29
ilaxi28-May-07 4:29 
AnswerRe: Security report icons on IE Pin
Sathesh Sakthivel28-May-07 4:31
Sathesh Sakthivel28-May-07 4:31 
Questionselect menustrip item by code Pin
hamid_m28-May-07 3:58
hamid_m28-May-07 3:58 
AnswerRe: select menustrip item by code Pin
Seishin#28-May-07 22:44
Seishin#28-May-07 22:44 
QuestionReportViewer.RefreshReport() takes too long time… Pin
anderslundsgard28-May-07 3:56
anderslundsgard28-May-07 3:56 
QuestionADO Paramater Class Pin
Sean Venter28-May-07 3:53
Sean Venter28-May-07 3:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.