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

Go Back  Xtreme .NET Talk > .NET > Windows Forms > draggable label c#


Reply
 
Thread Tools Display Modes
  #1  
Old 07-20-2004, 04:52 AM
alocin alocin is offline
Newcomer
 
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(){
InitializeComponent();
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)
{
dragStarted=true;
Console.WriteLine("startDrag " + dragStarted.ToString());
}
public void dragIt(object sender, MouseEventArgs e)
{
if(dragStarted)
{
this.label1.Location = new System.Drawing.Point(e.X , label1.Location.Y);
Console.WriteLine(label1.Location.X);
}else
Console.WriteLine("X");

}
public void stopDrag(object sender, MouseEventArgs e)
{
dragStarted = false;
Console.WriteLine("Stoppped..");
}
Reply With Quote
  #2  
Old 07-20-2004, 05:20 AM
Hamburger1984 Hamburger1984 is offline
Centurion

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

see attachment...

Hope this helps!

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

Bookmarks

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 07: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

Advertisement:







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.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
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..
subscribe