473,503 Members | 1,731 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Keeping controls centered

This is not actually a C# question but I'm not sure which newsgroup is
appropriate for
this question. My apologies if I'm being "off-topic".

I'm writing and application that has a group box that contains a bunch of
radio buttons
and wish to keep this group box and its buttons centered when the width of
the window
is changed. I do know how to accomplish this using code but I wonder if
there is a
simpler method? I'm using Visual Studio 2005 to write this application.

Regards
Chris Saunders
Feb 4 '07 #1
9 2041
On Feb 3, 9:57 pm, "Chris Saunders" <e...@mountaincable.netwrote:
This is not actually a C# question but I'm not sure which newsgroup is
appropriate for
this question. My apologies if I'm being "off-topic".

I'm writing and application that has a group box that contains a bunch of
radio buttons
and wish to keep this group box and its buttons centered when the width of
the window
is changed. I do know how to accomplish this using code but I wonder if
there is a
simpler method? I'm using Visual Studio 2005 to write this application.
You may be stuck doing this in code. The best chance you have for
doing it using layout containers would be the standard
TableLayoutPanel, but even that doesn't let you center things easily.
You could make a 3 x 3 table and put your control in the center. You
could then set the second row's RowStyle to Absolute, and the second
column's ColumnStyle to Absolute, and set the others to 50 Percent.

http://msdn2.microsoft.com/en-us/lib...rowstyles.aspx

If you're lucky, this will cause the center cell to stay the size you
want it, while allocating half the remaining space to the top and
bottom rows, and the right and left columns of the table layout. I
make no promises though: I haven't tried it myself. :-)

Also, check out the following;

http://msdn2.microsoft.com/en-us/library/ms171691.aspx
Feb 4 '07 #2
Chris Saunders wrote:
This is not actually a C# question but I'm not sure which newsgroup
is appropriate for this question. My apologies if I'm being
"off-topic".

I'm writing and application that has a group box that contains a
bunch of radio buttons and wish to keep this group box and its
buttons centered when the width of the window is changed. I do know
how to accomplish this using code but I wonder if there is a simpler
method? I'm using Visual Studio 2005 to write this application.
Simply anchor it only to the bottom of the form while pre-centering it
in the designer. Then when you resize the window, the groupbox will
stay centered.

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Feb 4 '07 #3
On Feb 4, 2:07 am, "Frans Bouma [C# MVP]"
<perseus.usenetNOS...@xs4all.nlwrote:
Chris Saunders wrote:
This is not actually a C# question but I'm not sure which newsgroup
is appropriate for this question. My apologies if I'm being
"off-topic".
I'm writing and application that has a group box that contains a
bunch of radio buttons and wish to keep this group box and its
buttons centered when the width of the window is changed. I do know
how to accomplish this using code but I wonder if there is a simpler
method? I'm using Visual Studio 2005 to write this application.

Simply anchor it only to the bottom of the form while pre-centering it
in the designer. Then when you resize the window, the groupbox will
stay centered.
Really! I had no idea!

Does that work in 1.1 as well as 2.0? Or is it a WPF thing?

Feb 4 '07 #4
"Bruce Wood" <br*******@canada.comwrote in message
news:11**********************@a34g2000cwb.googlegr oups.com...
On Feb 4, 2:07 am, "Frans Bouma [C# MVP]"
<perseus.usenetNOS...@xs4all.nlwrote:
>Chris Saunders wrote:
This is not actually a C# question but I'm not sure which newsgroup
is appropriate for this question. My apologies if I'm being
"off-topic".
I'm writing and application that has a group box that contains a
bunch of radio buttons and wish to keep this group box and its
buttons centered when the width of the window is changed. I do know
how to accomplish this using code but I wonder if there is a simpler
method? I'm using Visual Studio 2005 to write this application.

Simply anchor it only to the bottom of the form while
pre-centering it
in the designer. Then when you resize the window, the groupbox will
stay centered.

Really! I had no idea!

Does that work in 1.1 as well as 2.0? Or is it a WPF thing?
It's a .Net 2.0 Framework thing. It's easier in WPF (but it's about the
only thing that is). ;-)

Robin S.
Ts'i mahnu uterna ot twan ot geifur hingts uto.
Feb 4 '07 #5
RobinS wrote:
Robin S.
Ts'i mahnu uterna ot twan ot geifur hingts uto.

Too funny

http://malaysia.answers.yahoo.com/qu...7140330AA2L1AQ
Feb 4 '07 #6
RobinS wrote:
"Bruce Wood" <br*******@canada.comwrote in message
news:11**********************@a34g2000cwb.googlegr oups.com...
On Feb 4, 2:07 am, "Frans Bouma [C# MVP]"
<perseus.usenetNOS...@xs4all.nlwrote:
Chris Saunders wrote:
This is not actually a C# question but I'm not sure which
newsgroup >>is appropriate for this question. My apologies if I'm
being >>"off-topic".
>
I'm writing and application that has a group box that contains a
bunch of radio buttons and wish to keep this group box and its
buttons centered when the width of the window is changed. I do
know >>how to accomplish this using code but I wonder if there is a
simpler >>method? I'm using Visual Studio 2005 to write this
application.
>
Simply anchor it only to the bottom of the form while
pre-centering it
in the designer. Then when you resize the window, the groupbox
will stay centered.
Really! I had no idea!

Does that work in 1.1 as well as 2.0? Or is it a WPF thing?

It's a .Net 2.0 Framework thing. It's easier in WPF (but it's about
the only thing that is). ;-)

Nonsense, it works since .NET 1.0.

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Feb 5 '07 #7
Bruce Wood wrote:
On Feb 4, 2:07 am, "Frans Bouma [C# MVP]"
<perseus.usenetNOS...@xs4all.nlwrote:
Chris Saunders wrote:
This is not actually a C# question but I'm not sure which
newsgroup is appropriate for this question. My apologies if I'm
being "off-topic".
I'm writing and application that has a group box that contains a
bunch of radio buttons and wish to keep this group box and its
buttons centered when the width of the window is changed. I do
know how to accomplish this using code but I wonder if there is a
simpler method? I'm using Visual Studio 2005 to write this
application.
Simply anchor it only to the bottom of the form while
pre-centering it in the designer. Then when you resize the window,
the groupbox will stay centered.

Really! I had no idea!

Does that work in 1.1 as well as 2.0? Or is it a WPF thing?
It works since .NET 1.0 :)

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Feb 5 '07 #8

"Frans Bouma [C# MVP]" <pe******************@xs4all.nlwrote in message
news:xn***************@news.microsoft.com...
RobinS wrote:
>"Bruce Wood" <br*******@canada.comwrote in message
news:11**********************@a34g2000cwb.googleg roups.com...
On Feb 4, 2:07 am, "Frans Bouma [C# MVP]"
<perseus.usenetNOS...@xs4all.nlwrote:
Chris Saunders wrote:
This is not actually a C# question but I'm not sure which
newsgroup >>is appropriate for this question. My apologies if I'm
being >>"off-topic".
>
I'm writing and application that has a group box that contains a
bunch of radio buttons and wish to keep this group box and its
buttons centered when the width of the window is changed. I do
know >>how to accomplish this using code but I wonder if there is a
simpler >>method? I'm using Visual Studio 2005 to write this
application.
>
Simply anchor it only to the bottom of the form while
pre-centering it
in the designer. Then when you resize the window, the groupbox
will stay centered.

Really! I had no idea!

Does that work in 1.1 as well as 2.0? Or is it a WPF thing?

It's a .Net 2.0 Framework thing. It's easier in WPF (but it's about
the only thing that is). ;-)


Nonsense, it works since .NET 1.0.

FB
I stand corrected! Thanks!
Robin S.
Feb 5 '07 #9
My thanks to all who responded to this question. I've been ill so I didn't
see the responses until today.
The group box I wanted to stay centered was at the top of the window so I
anchored it to the top alone
and this worked fine. Thanks again.

Regards
Chris Saunders

"Frans Bouma [C# MVP]" <pe******************@xs4all.nlwrote in message
news:xn***************@news.microsoft.com...
Chris Saunders wrote:
>This is not actually a C# question but I'm not sure which newsgroup
is appropriate for this question. My apologies if I'm being
"off-topic".

I'm writing and application that has a group box that contains a
bunch of radio buttons and wish to keep this group box and its
buttons centered when the width of the window is changed. I do know
how to accomplish this using code but I wonder if there is a simpler
method? I'm using Visual Studio 2005 to write this application.

Simply anchor it only to the bottom of the form while pre-centering it
in the designer. Then when you resize the window, the groupbox will
stay centered.

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------

Feb 6 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
11088
by: Freek te Water | last post by:
Hi, Hope no-one is offended by my probably noob question... Context: I have a web page design, which always centres in the middle of the screen (using a 100%*100% HTML-table). Now I also use...
17
6865
by: No One | last post by:
Is there a way to keep a control centered inside a form without having to recalculate everytime the form is resized?
3
1344
by: Ryan Wade | last post by:
If the user resizes IE I want the webform controls to be automatically repositioned in the center of the form. How can I accomplish this? Ryan
15
2150
by: Arpan | last post by:
Consider the following code which retrieves data from a SQL Server 2005 DB table & displays it in a DataGrid: <script runat="server"> Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)...
7
2000
by: TheLongshot | last post by:
I just recently converted a few pages of my application to using master pages. Problem is, in all of my content pages, the contents are centered. I can't figure out why. The markup in the...
0
7087
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
7334
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7462
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
5579
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,...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
737
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
383
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.