473,407 Members | 2,315 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,407 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 4484
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Miki Tebeka | last post by:
Hello All, I have a frame that contains a panel and several buttons. I'd like to make one of the button the default button but self.SetDefaultItem(btn) or btn.SetFocus() don't work. The item in...
3
by: Lo?c Mah? | last post by:
Hello I try to use a Validator for a TxtCtrl placed in a Panel with a Button in order to trigger the Validator and test the content of TxtCtrl. I have looked into wxPython documentation and...
2
by: Alexander | last post by:
Hi, I have a simple Problem. I want to center a dialog on a panel of an application. I do the following: public class MyDialog : System.Windows.Forms.Form { private Panel m_ParentPanel; ...
11
by: Hoku | last post by:
I am using dual monitors on a dual head ATI AGP4x video card. I installed the Nov 11 2005 release of ATI's catalyst control center with Hydravision to manage the dual monitor setup. I recently...
7
by: Sharon | last post by:
I’m using the Panel control that contains a PictureBox control (for implementing the http://www.codeproject.com/cs/miscctrl/PictureBox.asp). The Panel is set to AutoScroll = true. I wish to...
2
by: Dinesh | last post by:
Dear All, Can u tell me how to center align a div (Panel) in Asp.Net 2.0. If we use align="center" then it will be converted to text-align:center which will align all the content of the div's...
11
by: Mel | last post by:
Does anyone know a way to center the info. on a webpage? I want my web site to work like MySpace.com where the page content remains centered when I resize the browser window. For the life of me I...
3
by: asit | last post by:
from Tkinter import * def callback(): print e.get() master=Tk() e=Entry(master) e.pack(anchor=CENTER)
7
by: raylopez99 | last post by:
I have a logical drawing space much bigger than the viewport (the screen) and I'd like to center the viewport (the screen) to be at the center of the logical drawing space. After following the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.