Mobile button in Windows form
I need to move a button inside the form, where ever I over mouse pointer on the form? can you please suggest any solution
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Selva GanapathyPosted Sep 24, 2014, 8:15 AM
Hi Jegan Priya,
You can achieve your requirement by following code
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Timer timer = new Timer();
timer.Interval = 10;
timer.Tick += timer_Tick;
timer.Start();
}
void timer_Tick(object sender, EventArgs e)
{
this.button1.Left = Cursor.Position.X - this.Left - this.button1 .Width /2;
this.button1.Top = Cursor.Position.Y - this.Top - 20 - this.button1.Height /2;
}
}
Regards,
Selva Ganapathy K
nathaJegamoorty PillaiPosted Sep 24, 2014, 8:17 AM