2
votes

I am unable to figure out how to make my user control react to the resize event of a form.
The usercontrol(s) exist in a tab control of my main form.
The usercontrol(s) are anchored to all sides of the tab control or is it tab page?
The tab control is anchored to all sides of the form.
When I resize my main form the tab control resizes correctly but the usercontrol does not.

[SUMMARY]
DataBoxUserControl
- A user control with a button and a textbox.
- The textbox has it's sides anchored to the usercontrol.

MainForm
- Has a tabcontrol that is anchored to all sides of the form.
- The tab controls have my DataBoxUserControl which has it's sides anchored to the tab control.

Resizing the MainForm resizes the tab control but not the user control.

[WHAT ELSE HAVE I TRIED]
1. I've tried placing a panel control in each tab page and anchoring the panel. Then I placed the user control in the panel and anchor it. Either I'm doing it wrong but that didn't work either.
2. I read somewhere to try register the resize event of the main form to the user control. But I don't really understand that and I can't seem to find where I saw that again.

I am using c# and .net 3.5

1
Have you tried using the Dock "Fill" property?Chris Thompson
Yes, all it does it just make my usercontrol not start at location 0,0 which means it trims my usercontrol as i've got the usercontrol size to start of being the size of the tabcontrol.Gavin Chin
@Chris Thompson: Thanks for the answer. Thought I had set the anchor in the usercontrol but seems like I didn't.Gavin Chin

1 Answers

2
votes

I believe you need to set the dock property of the user control to "fill" to have it auto resize to an area.