Centering a form?!?
-
I must be going mental or something because I can't for the life of me get one form to center on top of another. It seems to me that this code should work, but it doesn't.
this.Top = (this.Owner.Height / 2) - this.Height; // I've tried both + and -
this.Left = (this.Owner.Width / 2) + this.Width;but it never centers the form. What am I doing wrong here? - monrobot13
-
I must be going mental or something because I can't for the life of me get one form to center on top of another. It seems to me that this code should work, but it doesn't.
this.Top = (this.Owner.Height / 2) - this.Height; // I've tried both + and -
this.Left = (this.Owner.Width / 2) + this.Width;but it never centers the form. What am I doing wrong here? - monrobot13
-
Your formula is wrong... Try this:
this.Top = (this.Owner.Height - this.Height) / 2;
this.Left = (this.Owner.Width - this.Width) / 2; -
actually you should set the Location property. the top and left are old vb'er ways plus the form property has a center option property
Ista wrote: actually you should set the Location property. the top and left are old vb'er ways It's really irrelevant, a
Location
property is simple defined as aPoint
structure that sets theTop
andLeft
properties of the form. -Nick Parker -
Ista wrote: actually you should set the Location property. the top and left are old vb'er ways It's really irrelevant, a
Location
property is simple defined as aPoint
structure that sets theTop
andLeft
properties of the form. -Nick Parker -
relavancy has nothing to do with it really. I'm not an expert yet, but I play one at work. Yeah and here too.
Ista wrote: relavancy has nothing to do with it really :rolleyes: -Nick Parker
-
Ista wrote: relavancy has nothing to do with it really :rolleyes: -Nick Parker