471,355 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Center Button in PaneL

I have a usercontrol that has a panel as a band across the width of the user
control

When the usercontrol is diaplayed the button is not centered.
If I anchor the button to the panel Left/Top/Right the button get's streched
which I want to try to avoid.

Anyone have ideas on how to center the button in the panel not matter
the size of the panel??

Thanks
Sep 7 '07 #1
4 4299
"sippyuconn" <si********@newsgroup.nospamwrote in message
news:56**********************************@microsof t.com...
>I have a usercontrol that has a panel as a band across the width of the
user
control

When the usercontrol is diaplayed the button is not centered.
If I anchor the button to the panel Left/Top/Right the button get's
streched
which I want to try to avoid.

Anyone have ideas on how to center the button in the panel not matter
the size of the panel??
You can compute the position of the button during the Load event of your
control:

MyButton.Left = (MyPanel.ClientSize.Width-MyButton.Width)/2;
Sep 7 '07 #2
On Sep 7, 2:00 pm, sippyuconn <sippyuc...@newsgroup.nospamwrote:
I have a usercontrol that has a panel as a band across the width of the user
control

When the usercontrol is diaplayed the button is not centered.
If I anchor the button to the panel Left/Top/Right the button get's streched
which I want to try to avoid.

Anyone have ideas on how to center the button in the panel not matter
the size of the panel??

Thanks
Turn off the Left and Right anchoring. Leave just the Top anchoring
and nothing else (or even clear all of the Anchor properties if you
like).

The button should remain centred in the panel.

Sep 8 '07 #3
Hi,

Is your Panel docked or anchored in the UserControl? I assume not.

Then, I assume you want the Button in the Panel to be not resized during
the Form resizing. For this requirement, you may take the advices of both
Bruce and Alberto. That is: you may cancel the using of Anchor property(so
that the Button's size will not stretch with the parent control resizing)
and calculate the center position of the Button in Form.Load event. This
should do what you want.

If we have misunderstood you, please feel free to feedback, thanks.

Best regards,
Jeffrey Tan
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.

Sep 10 '07 #4
Hi,

Have you reviewed our replies to you? Do they make sense to you? If you
still need any help, please feel free to feedback,, thanks.

Best regards,
Jeffrey Tan
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.

Sep 17 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Miki Tebeka | last post: by
7 posts views Thread by Sharon | last post: by
2 posts views Thread by Dinesh | last post: by
11 posts views Thread by Mel | last post: by
3 posts views Thread by asit | last post: by
reply views Thread by XIAOLAOHU | last post: by

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.