forcing form to resize upon load  
Author Message
jaxitis





PostPosted: Tue May 11 19:07:01 CDT 2004 Top

Winforms >> forcing form to resize upon load

Hi! I am experiencing a peculiar problem with some old Active X control I am using in my C# winform. Once the form
loads, the control layout position withing the form is incorrect. As soon as I manually resize the form, the control's layout becomes as intended. I need to either fix the control (I am not sure if possible) or force the form to resize just a bit upon load. Is it possible
If yes, what can I do to do that?

Any ideas are greatly appreciated

Thank you in advance

--Sam D..

DotNet428  
 
 
AlexS





PostPosted: Tue May 11 19:07:01 CDT 2004 Top

Winforms >> forcing form to resize upon load Hi, Sam D.

You can do that in form load event. E.g. you can set initial width and
height, location etc.
See if it works

HTH
Alex



> Hi! I am experiencing a peculiar problem with some old Active X control I
am using in my C# winform. Once the form
> loads, the control layout position withing the form is incorrect. As soon
as I manually resize the form, the control's layout becomes as intended. I
need to either fix the control (I am not sure if possible) or force the form
to resize just a bit upon load. Is it possible?
> If yes, what can I do to do that?
>
> Any ideas are greatly appreciated.
>
> Thank you in advance,
>
> --Sam D...
>


 
 
AlexS





PostPosted: Tue May 11 21:08:48 CDT 2004 Top

Winforms >> forcing form to resize upon load Sam,

thanks for thanks. If it doesn't work, you can try other events, however,
it's like guessing game - no guaranteed results, right?

afair, your component reacts on manual resize. So one of next tries could be
to invoke resize event handler manually - maybe even in form.Load?

I don't remember now exact sequence of events in form life - you will have
to find out event which causes initial placement of control and do resize in
some event after that.

HTH
Alex




> Thank you, Alex. It does not work. Any ideas ?
>
> Many Thanks in Advance,
>
> --Sam


 
 
Mark





PostPosted: Wed May 12 05:33:13 CDT 2004 Top

Winforms >> forcing form to resize upon load you could create a private form class var e.g.
private bool firedResizeOnce = false;

and within the Activate event do something similar (it will only fire once a
instanciation)

if (!firedResizeOnce) {

//never resize again on this instance

firedResizeOnce = true;

int formWidth = this.Height * 2;

int formHeight = this.Width * 2;

System.Drawing.Size s = new Size(formWidth, formHeight);

//resize form to new size

this.Size = s;

}


Obviously there will be a very (milli secs or so) momentary visible change
but it really shouldnt be a problem.
--

--

Br,
Mark Broadbent
mcdba , mcse+i
=============


> Sam,
>
> thanks for thanks. If it doesn't work, you can try other events, however,
> it's like guessing game - no guaranteed results, right?
>
> afair, your component reacts on manual resize. So one of next tries could
be
> to invoke resize event handler manually - maybe even in form.Load?
>
> I don't remember now exact sequence of events in form life - you will have
> to find out event which causes initial placement of control and do resize
in
> some event after that.
>
> HTH
> Alex
>
>


> > Thank you, Alex. It does not work. Any ideas ?
> >
> > Many Thanks in Advance,
> >
> > --Sam
>
>