forcing form to resize upon load

G

Guest

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..
 
A

AlexS

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

Sam D. said:
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?
 
A

AlexS

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
 
M

Mark Broadbent

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
=============
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top