Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Winform - Groupbox & Controls?

Tags:

winforms

In a Winform I have a groupbox and in it several Textbox controls. If I delete the Groupbox the Textboxes get deleted as well. They are somehow tied to the Groupbox though I didn't do anything knowingly for this to happen. Question - how can I remove this connection, so that I can delete the groupbox and still have the textboxes on the form?

like image 405
Alex Avatar asked Jan 26 '26 21:01

Alex


1 Answers

In the Designer.cs file you'll have a series of lines of code like :

this.groupBox1.Controls.Add(this.textBox2);
this.groupBox1.Controls.Add(this.textBox1);

change them to say :

this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);

this will make their container the form rather than the groupbox, and you can delete the groupbox after that. This will however move the textboxes, as their Position values are relative to their container which was the Groupbox.

like image 121
MartW Avatar answered Jan 29 '26 09:01

MartW



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!