Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,466 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have a text box and I want to leave it in the same place relative to the image
One of the ways is with a FlowLayoutPanel
A test with
Anchor : Bottom, Right
and
Margin 50; 50; for the TextBox
=>
You can also override WM_SIZING .
Random test =>
private void MoveSize()
{
// Resize/Move controls as you want
pictureBox1.Left = (this.ClientSize.Width - pictureBox1.Width) / 2;
pictureBox1.Top = (this.ClientSize.Height - pictureBox1.Height) / 2;
// textBox1 relative to pictureBox1
textBox1.Left = pictureBox1.Left + 100;
textBox1.Top = pictureBox1.Bottom + 20;
}
public const int WM_SIZING = 0x0214;
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == WM_SIZING)
{
MoveSize();
m.Result = (IntPtr)1;
}
}