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

stretching components upon a user-window-resize action

P: n/a
In a Windows Form application, when a user resizes the window, I typically
want different components in the form to take different actions. For
example, a text box in the middle should grow with the window; a button
panel at the bottom should remain the same height but re-center
horizontally; etc.

What I have settled on as a technique for managing this is to start witha
table container (dock=fill), then by combining rowspans, columnspans, and
absolute vs percentage row/column sizes, I can achieve fine control over
layout when the form is resized. I am just wondering if that is considered
a good approach or if there is a different Best Practice for this?
Nov 13 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"michael sorens" <m_********@community.nospamwrote in
news:op***************@spo-cont-2-dt.itron.com:
What I have settled on as a technique for managing this is to start
with a table container (dock=fill), then by combining rowspans,
columnspans, and absolute vs percentage row/column sizes, I can
achieve fine control over layout when the form is resized. I am just
wondering if that is considered a good approach or if there is a
different Best Practice for this?
Have you tried using anchors + docks?
Nov 13 '06 #2

P: n/a
No, I had not tried anchors. I can see they provide some good tools for
this as well.
Nov 14 '06 #3

P: n/a
Hi Michael,

I think your solution of using TableLayoutPanel control is perfect. In
fact, TableLayout is a new control shipped with VS 2005 and is designed to
rearrange the controls on the form when the form is resized.

Before the TableLayoutPanel control is available, we usually make use of
the Anchor or Dock property of the control to rearrange it when the form is
resized.

Anchoring a control to its parent control ensures that the anchored edges
remain in the same position relative to the edges of the parent control
when the parent control is resized. In your scenario, you could set the
Anchor property of the textbox to Left and Right.

Control's Dock property gets or sets which control borders are docked to
its parent control and determines how a control is resized with its parent.

Use the Dock property to define how a control is automatically resized as
its parent control is resized. For example, setting Dock to DockStyle.Left
causes the control to align itself with the left edges of its parent
control and to resize as the parent control is resized.

Note that the Anchor and Dock properties are mutually exclusive. Only one
can be set at a time, and the last one set takes precedence.

Hope this helps.
If you have anything unclear, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

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

Nov 14 '06 #4

P: n/a
Thank you, Linda, for some good pointers!
Nov 17 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.