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

Keeping controls centered

P: n/a
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
Share this Question
Share on Google+
9 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
"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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a

"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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.