473,386 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Compound Custom Control - How to Trap Resize in Design Mode

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
4 4172
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Matt Fielder | last post by:
I have developed a custom control to be used in my application. My application includes a form designer, so the control can be hosted while designmode for the control is either true or false,...
0
by: Chubby Arse | last post by:
Hi all, I have a control, that basically is my own version of the datagrid, except that is renderers purely readonly tabular information. When the control is rendered to the designer, I can...
0
by: James | last post by:
I have a composite custom control which is constructed of several other controls, such as command buttons, a listview etc. I have several controls which border the boundary of the container and have...
4
by: ThunderMusic | last post by:
Hi, I have a custom form that works fine when I debug it or run it in release mode but cannot be loaded in the designer... Actually, it can be loaded in the designer when no control is on it, but...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
9
by: Gord | last post by:
In VB6, a custom dialog can be easily created by adding a new form, adding whatever controls you like, sizing it as you like, adding code and then just loading/unloading it whenever you like....
2
by: DaveL | last post by:
Hello, I have a Custome Control which contains TextBox Button DataGridView design is Textbox , button When a user clicks the button i resize the custom control canvasarea to expose the...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.