Re: Designer doesn't update the window/form region based on subclassing
- From: v-lliu@xxxxxxxxxxxxxxxxxxxx (Linda Liu [MSFT])
- Date: Thu, 29 Mar 2007 05:11:43 GMT
Hi Liviu,
Thank you for your prompt response and sample project. I understand your
question exactly now.
You may add the following statement before the code 'this.Region = new
Region(Drawing.GetRoundedRectangle(new Rectangle(0, 0, this.Size.Width,
this.Size.Height), 0.3f));' in the Form1's Load event handler:
MessageBox.Show(this.Size.ToString());
Build the project and re-open Form2 in the designer. You should see a
message box pops up showing the size of Form1, not the size of Form2.
As I have explained in my first reply, when we open a derived form in the
designer, an instance of the base form is created. Thus the constructor of
the base form is called and then the Load event handler. It's after the
instance of the base form finishes the construction and load that the
IntializeComponent method of the derived form is called.
That's to say, in your sample project, when the Form1's Load event handler
is called, the size of the Form2 is equal to that of the Form1. So the
region is set based on the size of the Form1.
As I have mentioned, this behavior is by design. I think there're two
options for you to solve this problem.
One option is what I have provided in my first reply, i.e. add a condition
of "!this.DesignMode" to prevent the code of setting region from being
called at design time. This option will cause the Form2 to loose the
'region' behavior at design time(but the Form2 still has the 'region'
bebavior at run time).
The other option is to move the code of setting region to the Resize event
handler of the Form1. The Resize event of the base form will ocurr no
matter at design time or run time, as long as the size of the derived form
is changed. This option enables the Form2 to have the 'region' behavior at
design time.
I perfer the second option.
Hope this helps.
If you have anything unclear, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support
.
- Follow-Ups:
- Re: Designer doesn't update the window/form region based on subclassing
- From: Liviu Balan
- Re: Designer doesn't update the window/form region based on subclassing
- References:
- Designer doesn't update the window/form region based on subclassing
- From: Liviu Balan
- RE: Designer doesn't update the window/form region based on subclassing
- From: Linda Liu [MSFT]
- Re: Designer doesn't update the window/form region based on subclassing
- From: Liviu Balan
- Designer doesn't update the window/form region based on subclassing
- Prev by Date: RE: ScrollBars and UserControl
- Next by Date: Re: ScrollBars and UserControl
- Previous by thread: Re: Designer doesn't update the window/form region based on subclassing
- Next by thread: Re: Designer doesn't update the window/form region based on subclassing
- Index(es):
Relevant Pages
|