c# - How do you resize a form to fit its content automatically? -


i trying implement following behaviour:

on form there tabcontrol. on tabcontrol there treeview. prevent scrollbars appearing, form change size according contents of treeview when displayed first time.

if treeview has many nodes displayed on default size of form, form should change it's size there no vertical scrollbar on treeview (up maximum size allowed size of screen).

what need know is, if possible achieve behaviour through properties of controls. i'm sure can achieved calculating , settings sizes of elements programmatically, know if there way achieve settings autosizemode etc.

[update]

it's first dialog user of application sees: it's dialog select database work with. it's list of databases, tabcontrol, buttens etc. if list long, scrollbars appear , colleague of mine wants them disappear.

use autosize , autosizemode properties.

http://msdn.microsoft.com/en-us/library/system.windows.forms.form.autosize.aspx

an example:

private void form1_load(object sender, eventargs e) {     // no smaller design time size     this.minimumsize = new system.drawing.size(this.width, this.height);      // no larger screen size     this.maximumsize = new system.drawing.size(screen.primaryscreen.bounds.width, screen.primaryscreen.bounds.height, (int)system.windows.systemparameters.primaryscreenheight);      this.autosize = true;     this.autosizemode = autosizemode.growandshrink;      // rest of code here... } 

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -