Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to dynamically resize a textbox in C#

Tags:

c#

winforms

I am new to C# user interface. I have created a window as shown in the first image. But if the user drag the window and make it bigger, I would like for it to make each richTextBox expand with it as shown in the second image. For example, make the richTextBox4 bigger proportional to the size of the window. Any ideas would be greatly appreciated

Image1:

Image 1

Image 2: enter image description here

like image 884
Learner_51 Avatar asked Sep 11 '25 19:09

Learner_51


1 Answers

You can add a TableLayoutPanel to your Form. Per default this panel has two columns and two rows.

Then you add one TextBox to each cell and set the Dock-Property of each TextBox to Fill.

The last step thing to do is either set the Dock-Property of your TableLayoutPanel to Fill or set the Anchor-Property of your TableLayoutPanel to Left | Right | Bottom | Top. Then your panel will be resized together with the Form.

All these steps can be done with the designer.

like image 131
Tomtom Avatar answered Sep 13 '25 09:09

Tomtom