Windows Develop Bookmark and Share   
 index > Windows Forms General > Standard way to dynamically resize a DialogBox (with right/bottom aligned OK/Cancel buttons)?
 

Standard way to dynamically resize a DialogBox (with right/bottom aligned OK/Cancel buttons)?

Hi,
writing in VB on VS2008, targetting framework 3.5

I have a custom DialogBox whose main control can change size depending on how certain parts are configured.

I would like to be able to automatically resize the DialogBox with the borders of the DialogBox remaining the same size in relation to the main control element (a UserControl).

Can anyone recommend a way to do this using standard Windows Forms elements, or am I going to have to manually code the resize methods?

I tried using the simple AutoSize = True, AutoSizeMode = GrowAndShrink setting, but the fact that the TableLayoutPanel containing the OK and Cancel buttons seems to stop that from functioning at all. The DialogBox Window never resizes, no matter the size of the main form component.

It's no problem if not, I was just wondering if there was some standard way to perform this function, keeping in mind that the DialogBox is a fairly standard item, and someone might have done it before.

Cheers.
KFrostILEM  Thursday, October 01, 2009 3:54 PM
As far as I know, the DialogBox is meant to be a fixed or user-defined size. You can then resize the controls to fit within it using properties such as Anchor or controls such as one of the layout panels.

A dialogbox is not set up to automatically resize.

I can understand the philosophy behind this.

Say you are running on a 1024 x 768 system. Suddenly the dialog grows to the point that you can no longer access the OK/Cancel buttons because they are off the screen. This could be very disconcerting.

Rather, you can set scrollbars such that the user can see the parts of the form beyond the size of the dialog.

But if you *really* need this feature, you will need to code it yourself.

Hope this helps.
www.insteptech.com ; msmvps.com/blogs/deborahk
We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS!
DeborahK  Wednesday, October 07, 2009 12:41 AM
As far as I know, the DialogBox is meant to be a fixed or user-defined size. You can then resize the controls to fit within it using properties such as Anchor or controls such as one of the layout panels.

A dialogbox is not set up to automatically resize.

I can understand the philosophy behind this.

Say you are running on a 1024 x 768 system. Suddenly the dialog grows to the point that you can no longer access the OK/Cancel buttons because they are off the screen. This could be very disconcerting.

Rather, you can set scrollbars such that the user can see the parts of the form beyond the size of the dialog.

But if you *really* need this feature, you will need to code it yourself.

Hope this helps.
www.insteptech.com ; msmvps.com/blogs/deborahk
We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS!
DeborahK  Wednesday, October 07, 2009 12:41 AM

You can use google to search for other answers

Custom Search

More Threads

• VB.NET 2005 - Web Browser - New Window
• Question about GridView
• DataGridView Column Header Style
• How do you get the My Documents directory?
• .net Control inheritance forum, club.. website anywhere?
• Showing multiple window forms on one form?
• Print HTML
• suppressing automatic scrolling within FlowLayoutPanel with AutoScroll
• problem in accessing controls ????
• How to draw on top of the form