Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

userControl - what event fires when resized

Status
Not open for further replies.

sodakotahusker

Programmer
Mar 15, 2001
601
I am rolling my own userControl with a ton of functionality. I can't figure out what event fires when the user resizes their instance of the control so I can adjust the widths of embedded controls - treeview and webbrowser. In the activeX world there was a Usercontrol set of events and one was called Resize or something like that. Perhaps I need to include an overload method for the UserControl class? Can anybody point me in the right direction? Thanks!
 
Most WinForms controls, including UserControl, have the Resize event property (you can see this on the Properties toolwindow). You can add an event handler, or override the OnResize() method.
Code:
ctrl.Resize += new EventHandler(this.ctrlResizeHandler);
..or
Code:
protected override void OnResize(EventArgs e) {
   base.OnResize (e);
}
 
Also, you can usually use properties like Dock and Anchor that will take care of the resizing automatically for you.

Become familiar with these properties as they are often crucial in modern interface Design.
 
OOps. Another post came in that I did not see.
I tried to use the anchor but that did not work. However I was spacing when I was trying this. I resized the host form by using the maximize button. The user control was not tied to that event. I had to add a resize event to my host form which then resized the user control if necessary. I would need to apply the anchor in that host form as well. I'll try that too. Thanks to both of you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top