By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,515 Members | 1,363 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,515 IT Pros & Developers. It's quick & easy.

Compound Custom Control - How to Trap Resize in Design Mode

P: n/a
I have a compound custom control derived from UserControl. It has three controls on it -- two
custom controls and a Label control. When the control is added to a from and then resized using the
Designer how do I trap the resize event so I can resize the child controls?

I have tried the using:
protected override void OnSizeChanged(EventArgs e)

But it doesn't get called when the control is resized in the Designer.
Nov 20 '08 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Actually, it is called -- just breakpoints don't work.

Stewart Berman <sa******@nospam.nospamwrote:
>I have a compound custom control derived from UserControl. It has three controls on it -- two
custom controls and a Label control. When the control is added to a from and then resized using the
Designer how do I trap the resize event so I can resize the child controls?

I have tried the using:
protected override void OnSizeChanged(EventArgs e)

But it doesn't get called when the control is resized in the Designer.
Nov 21 '08 #2

P: n/a
On Wed, 19 Nov 2008 19:36:37 -0800, Stewart Berman
<sa******@nospam.nospamwrote:
I have a compound custom control derived from UserControl. It has
three controls on it -- two
custom controls and a Label control. When the control is added to a
from and then resized using the
Designer how do I trap the resize event so I can resize the child
controls?
As you've found, you can in fact override the usual methods.

That said, unless you have some specific layout criteria that's not
addressable any other way, it would generally make more sense to just
configure your child controls in the UserControl so that they are
anchored, docked, in a separate layout-specific container (e.g.
FlowLayoutPanel), etc. as appropriate for your needs so that they
automatically respond to resize events.

Pete
Nov 21 '08 #3

P: n/a
I am just getting back into this after a long stretch in the Access/Excel world. Since I started
programming Windows Apps in C and a little assembler (before C++ was thought of much less available)
my initial response to any special need is to roll my own. I appreciate the note and have to
remember to see what's available before reinventing the wheel.

OTOH, it is interesting to see what can be done at the lower levels.

"Peter Duniho" <Np*********@nnowslpianmk.comwrote:
>On Wed, 19 Nov 2008 19:36:37 -0800, Stewart Berman
<sa******@nospam.nospamwrote:
>I have a compound custom control derived from UserControl. It has
three controls on it -- two
custom controls and a Label control. When the control is added to a
from and then resized using the
Designer how do I trap the resize event so I can resize the child
controls?

As you've found, you can in fact override the usual methods.

That said, unless you have some specific layout criteria that's not
addressable any other way, it would generally make more sense to just
configure your child controls in the UserControl so that they are
anchored, docked, in a separate layout-specific container (e.g.
FlowLayoutPanel), etc. as appropriate for your needs so that they
automatically respond to resize events.

Pete
Nov 21 '08 #4

P: n/a
Hello Stewart ,

Thank you for using Microsoft Managed Newsgroup Service, I'm Zhi-Xin Ye,
it's my pleasure to work with you on this issue.

You can override the the OnSizeChanged method to adjust the size for the
child controls, however, the formal way to resize/relocation the child
controls is to set the Anchor property or Dock property, then the child
controls would automatically adjust their size/location when the parent
container resizes.

For more information, you can refer to these document:

Control.Anchor Property
http://msdn.microsoft.com/en-us/libr...control.anchor.
aspx

Control.Dock Property
http://msdn.microsoft.com/en-us/libr...ontrol.dock.as
px

If you have any questions or concerns, please feel free to let me know.

Have a great day!

Sincerely,
Zhi-Xin Ye
Microsoft Managed Newsgroup Support Team

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.