@Artjom Schmitke , I want to know if this happened in the designer or at runtime. If you want to move the control at runtime, you could try to use Mouse_Move event and Mouse_Down event to move the buttons in the TabPage.
Code:
private Point MouseDownLocation;
private void Form1_Load(object sender, EventArgs e)
{
Button btn1 = new Button();
btn1.Text = "test";
btn1.Location = new Point(0, 0);
btn1.MouseDown += Btn1_MouseDown;
btn1.MouseMove += Btn1_MouseMove;
tabPage1.Controls.Add(btn1);
}
private void Btn1_MouseMove(object sender, MouseEventArgs e)
{
Button btn = sender as Button;
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
btn.Left = e.X + btn.Left - MouseDownLocation.X;
btn.Top = e.Y + btn.Top - MouseDownLocation.Y;
}
}
private void Btn1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
MouseDownLocation = e.Location;
}
}
Result:
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.