Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Winforms Resizing and Controls

Tags:

c#

winforms

Say I have a Winform with 3 adjacent Textboxes, all within a Panel that covers the majority of the form. How can I configure it so that when I resize the form, the controls also resize, but do not bleed into each other? I've tried the different anchoring options, however the textboxes always tend to run into each other?

It's probably something really simple that i've missed.

Thanks.

like image 663
Darren Young Avatar asked Dec 28 '22 22:12

Darren Young


2 Answers

One easy way to accomplish this is to put the three textboxes into a TableLayoutPanel that has 1 row and three columns.

Settings:

  • Set the width of each column to 33%
  • Set the anchor properties of the TableLayoutPanel to Top, Left, Right (or similar).
  • Set the Dock property of each TextBox to Fill.
like image 82
RQDQ Avatar answered Jan 12 '23 06:01

RQDQ


Have a look at the TableLayoutPanel - you should be able to get the sort of behaviour you want using one of those with 3 columns and a text box in each one.

like image 33
Mike Goatly Avatar answered Jan 12 '23 06:01

Mike Goatly