WinForm embedded in a Tab control doesn't resize

BazE30

New member
Joined
Mar 20, 2012
Messages
1
Programming Experience
10+
Hi all,

My first post but none the less, I might as well ask for help with something I can't figure out.
VS Studio 2010. .NET framework 4.0

I have a MDI main form in which I have added a tab control to. The reason for this is that I want to have a tab for all opened windows much like an internet browser. This tab control is anchored top / left/ right /bottom. So whenever a new form is 'opened', I create a new tab and add the form as a control to the tab. This works fine for me in all respects as it loads the form correctly and all form textboxes etc are resized to the tab size dimensions. My problem arises when I resize the MDI form (like a user might do normally). The form itself doesn't resize with the MDI resize event. I have checked the tab control resize event and it is being invoked by the MDI resize event. but just not the form control resize event. Its not a big deal for me at the moment but I can't figure out how to notify that form that it needs to resize itself.

I thought that whenever the resize event occurs, that I loop through each tab child control and set the width / height of the form control. It doesn't seem to work either. I have tried using dock fill and all the anchor options but neither seem to work for me.

My question is, does anyone know of a workaround for invoking a resize event of a form that is embedded into a tab control? Or have you come across this problem before and see no resolution to it?

Kind regards
Barry
 
If you want to dynamically fill the control (form in your case) in container (tabpage in your case) you would normally set the controls Dock property to Fill.
 
Hi all,

My first post but none the less, I might as well ask for help with something I can't figure out.
VS Studio 2010. .NET framework 4.0

I have a MDI main form in which I have added a tab control to. The reason for this is that I want to have a tab for all opened windows much like an internet browser. This tab control is anchored top / left/ right /bottom. So whenever a new form is 'opened', I create a new tab and add the form as a control to the tab. This works fine for me in all respects as it loads the form correctly and all form textboxes etc are resized to the tab size dimensions. My problem arises when I resize the MDI form (like a user might do normally). The form itself doesn't resize with the MDI resize event. I have checked the tab control resize event and it is being invoked by the MDI resize event. but just not the form control resize event. Its not a big deal for me at the moment but I can't figure out how to notify that form that it needs to resize itself.

I thought that whenever the resize event occurs, that I loop through each tab child control and set the width / height of the form control. It doesn't seem to work either. I have tried using dock fill and all the anchor options but neither seem to work for me.

My question is, does anyone know of a workaround for invoking a resize event of a form that is embedded into a tab control? Or have you come across this problem before and see no resolution to it?

Kind regards
Barry

Or have you come across this problem before and see no resolution to it?

I've come across the same problem. As you stated, I've tried many things but nothing seems to work, (Dock = fill, Anchor=All, windowstate=max, AutoSize=true)

I captured the parent tabPage in the debugger and find that while the tabPage is resized, the form isn't. In this event I've tried setting the size, using the refresh and Update events to no avail. My only guess at this point is that when setting the form.toplevel = false it prevents from resizing. I'm actually puzzled that it can't be manually resized during the tabPage's event.
 
Or have you come across this problem before and see no resolution to it?

I've come across the same problem. As you stated, I've tried many things but nothing seems to work, (Dock = fill, Anchor=All, windowstate=max, AutoSize=true)

I captured the parent tabPage in the debugger and find that while the tabPage is resized, the form isn't. In this event I've tried setting the size, using the refresh and Update events to no avail. My only guess at this point is that when setting the form.toplevel = false it prevents from resizing. I'm actually puzzled that it can't be manually resized during the tabPage's event.

I did manange to create a workaround. It's really old school, reminds me of VB5. I have the form window state set to Maximize when it is created.

In the TapPage Resize event, set the Form.WindowState to Normal, then set it to Maximize. This is the only way I found to change the size. If I set the state to Normal to begin with teh form never shows.
 
Back
Top