N
No One
Is there a way to keep a control centered inside a form without having
to recalculate everytime the form is resized?
to recalculate everytime the form is resized?
No One,
Yes, there is. When the control is first placed on the form, perform
the calcs to center the control. Once you do that, set the Anchor property
so that it anchors to all sides of its container. If you are placing the
control in the container at design time, then just center the control and
set the Anchor property at design time.
Hope this helps.
Morten Wennevik said:makes sure the distance to the side is constant, and if you anchor both upThis will have the side effect of resizing the control though. Anchoring
and down or left and right it will resize the control. I am afraid you will
have to recalculate the position in the Form's SizeChanged event.
No One said:Is there a way to keep a control centered inside a form without having
to recalculate everytime the form is resized?
John Wood said:I doubt he would want the size of the control to remain constant, and have
the margin around it growing and shrinking, that would look just weird. And,
in fact, would seem like a candidate to have a fixed dialog border.
An alternative to Nicholas' suggestion - set the Dock property of the object
to Fill, and adjust the DockPadding property of the form to set the margin
size.
--
John Wood
EMail: first name, dot, second name at priorganize.com
Morten Wennevik said:makes sure the distance to the side is constant, and if you anchor both upThis will have the side effect of resizing the control though. Anchoring
and down or left and right it will resize the control. I am afraid you will
have to recalculate the position in the Form's SizeChanged event.
clintonG said:What am I missing here?
Why not simply use HTML <div align="center"> to center the control?
--
<%= Clinton Gallagher
A/E/C Consulting, Web Design, e-Commerce Software Development
Wauwatosa, Milwaukee County, Wisconsin USA
NET csgallagher@ REMOVETHISTEXT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/
John Wood said:I doubt he would want the size of the control to remain constant, and haveThis will have the side effect of resizing the control though. <<
the margin around it growing and shrinking, that would look just weird. And,
in fact, would seem like a candidate to have a fixed dialog border.
An alternative to Nicholas' suggestion - set the Dock property of the object
to Fill, and adjust the DockPadding property of the form to set the margin
size.
John Wood said:well um, he said form not web page.
--
John Wood
EMail: first name, dot, second name at priorganize.com
clintonG said:What am I missing here?
Why not simply use HTML <div align="center"> to center the control?
--
<%= Clinton Gallagher
A/E/C Consulting, Web Design, e-Commerce Software Development
Wauwatosa, Milwaukee County, Wisconsin USA
NET csgallagher@ REMOVETHISTEXT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/
John Wood said:This will have the side effect of resizing the control though. <<
I doubt he would want the size of the control to remain constant, and have
the margin around it growing and shrinking, that would look just weird. And,
in fact, would seem like a candidate to have a fixed dialog border.
An alternative to Nicholas' suggestion - set the Dock property of the object
to Fill, and adjust the DockPadding property of the form to set the margin
size.
--
John Wood
EMail: first name, dot, second name at priorganize.com
On Tue, 22 Jun 2004 08:18:05 -0400, Nicholas Paldino [.NET/C# MVP]
No One,
Yes, there is. When the control is first placed on the form,
perform
the calcs to center the control. Once you do that, set the Anchor
property
so that it anchors to all sides of its container. If you are placing
the
control in the container at design time, then just center the control
and
set the Anchor property at design time.
Hope this helps.
This will have the side effect of resizing the control though. Anchoring
makes sure the distance to the side is constant, and if you anchor both up
and down or left and right it will resize the control. I am afraid you will
have to recalculate the position in the Form's SizeChanged event.
several controls positioned on a form, I want them to maintain their height,B. Chernick said:I've been thinking about a similar problem. The problem is this: Given
something at TechEd 2001 to the effect that there was built-in resizing. AtWhat has me doubting my memory is that I could have sworn I heard
John said:I doubt he would want the size of the control to remain constant, and have
the margin around it growing and shrinking, that would look just weird. And,
in fact, would seem like a candidate to have a fixed dialog border.
An alternative to Nicholas' suggestion - set the Dock property of the object
to Fill, and adjust the DockPadding property of the form to set the margin
size.
I read "centered inside a form" with the emphasis on 'inside'
meaning declared HTML that if and when the form is processed
on the server the response will be rendered as HTML regardless.
A span or div element should be all that is needed unless again, I am
really missing the boat. Its not like I have not actually met more than
a handful of developers who can code in their sleep but are literally
HTML clueless. I'm just asking what seemed to be obvious to me...
<%= Clinton Gallagher
John Wood said:well um, he said form not web page.
--
John Wood
EMail: first name, dot, second name at priorganize.com
clintonG said:What am I missing here?
Why not simply use HTML <div align="center"> to center the control?
--
<%= Clinton Gallagher
A/E/C Consulting, Web Design, e-Commerce Software Development
Wauwatosa, Milwaukee County, Wisconsin USA
NET csgallagher@ REMOVETHISTEXT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/
This will have the side effect of resizing the control though. <<
I doubt he would want the size of the control to remain constant, and have
the margin around it growing and shrinking, that would look just weird. And,
in fact, would seem like a candidate to have a fixed dialog border.
An alternative to Nicholas' suggestion - set the Dock property of the object
to Fill, and adjust the DockPadding property of the form to set the margin
size.
--
John Wood
EMail: first name, dot, second name at priorganize.com
On Tue, 22 Jun 2004 08:18:05 -0400, Nicholas Paldino [.NET/C# MVP]
No One,
Yes, there is. When the control is first placed on the form,
perform
the calcs to center the control. Once you do that, set the Anchor
property
so that it anchors to all sides of its container. If you are placing
the
control in the container at design time, then just center the control
and
set the Anchor property at design time.
Hope this helps.
This will have the side effect of resizing the control though. Anchoring
makes sure the distance to the side is constant, and if you anchor both up
and down or left and right it will resize the control. I am afraid you will
have to recalculate the position in the Form's SizeChanged event.
several controls positioned on a form, I want them to maintain their height,B. Chernick said:I've been thinking about a similar problem. The problem is this: Given
something at TechEd 2001 to the effect that there was built-in resizing. AtWhat has me doubting my memory is that I could have sworn I heard
John said:So why not just make the border non-resizable?
Seems a bit odd to have something centered... why is the form resizable at
all in this case?