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

Form.ClientSize inconsistently firing Resize event

P: n/a
We have form that is used as the base class of all of our forms, let's
call it BaseApplicationForm. We have another form, say
ChildApplicationForm that inherits from BaseApplicationForm.

The child form implements an event handler for the Resize event.
Inside BaseApplicationForm.InitializeComponent, this.ClientSize is set
to a value. On most of our developers' machines, this.ClientSize =
....; does NOT fire the Resize event, which makes us happy, because the
object isn't finished being constructed yet, and our Resize event
handler should be able to assume that the object it is resizing, you
know, actually exists yet.

The problem is that on 2 of our developer machines, "this.ClientSize =
....;" DOES fire the event.

So, on these two troublesome machines, here is the order of events we
see as we step through:

We step to the very start of the ChildApplicationForm constructor.
This constructor contains a call to its own InitializeComponent, but of
course that won't be executed until the base constructor is executed in
full. So we step, which jumps to the base class constructor. Stepping
through the base class constructor, we arrive at the "this.ClientSize =
....;" line, and rather than moving to the next line, it jumps to the
CHILD class resize event handler. Inside that handler, we refer to
member variables (controls) that are still null, since
ChildApplicationForm.InitializeComponent has yet to be called.

For the rest of us, the event never fires during construction, so
everything works fine.

So, here are my questions: In this parent class / child class
situation, when the parent class' constructor tries to set
this.ClientSize, *should* the resize event be fired? If so, why does
it not do so for most of us. If not, why does it ever get fired for
some of us?

Jan 17 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.