Windows Forms Topics include: windows forms, controls, components and designers

Enjoy an ad free experience by logging in. Not a member yet? Register.
Go Back  Xtreme .NET Talk > .NET > Windows Forms > draggable label c#

Thread Tools Display Modes
Old 07-20-2004, 03:52 AM
alocin alocin is offline
Join Date: Jul 2004
Posts: 5
alocin is on a distinguished road
Question draggable label c#

i put a label into a form and i would like to drag it Horizontally...
but this code has some side effects...
the label don't follow exactly the mouse but jumps right-left continously...
do u know why?

public Form1(){
dragStarted = false;

this.label1.MouseDown += new MouseEventHandler(startDrag);
this.label1.MouseMove += new MouseEventHandler(dragIt);
this.label1.MouseUp += new MouseEventHandler(stopDrag);
private bool dragStarted;

public void startDrag(object sender, MouseEventArgs e)
Console.WriteLine("startDrag " + dragStarted.ToString());
public void dragIt(object sender, MouseEventArgs e)
this.label1.Location = new System.Drawing.Point(e.X , label1.Location.Y);

public void stopDrag(object sender, MouseEventArgs e)
dragStarted = false;
Reply With Quote
Old 07-20-2004, 04:20 AM
Hamburger1984 Hamburger1984 is offline

Preferred language:
Join Date: Jun 2003
Location: Hamburg,Germany
Posts: 162
Hamburger1984 is on a distinguished road

see attachment...

Hope this helps!

Attached Files
File Type: zip (7.9 KB, 26 views)
Reply With Quote


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Draggable form puma Windows Forms 2 06-09-2004 06:40 AM
Label Format Scooter ASP.NET 3 03-24-2004 11:51 PM
Label of a cd wessamzeidan Directory / File IO / Registry 1 03-20-2004 08:11 PM
how to transparent label? goodmorningsky Windows Forms 12 12-15-2003 08:19 AM


Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..