RE: Designer doesn't update the window/form region based on subclassing
- From: v-lliu@xxxxxxxxxxxxxxxxxxxx (Linda Liu [MSFT])
- Date: Wed, 28 Mar 2007 07:57:37 GMT
Hi Liviu,
I am sorry that I may not understand your question exactly.
Now if a new form(Form2) is created that subclasses Form1 the designerwill restrict the viewable portion to the default size of Form1.
What do you mean by "the default size"?
Below is my test and comments.
I set the Region property of Form1in its Load event handler as follows:
private void Form1_Load(object sender, EventArgs e)
{
System.Drawing.Drawing2D.GraphicsPath path = new
System.Drawing.Drawing2D.GraphicsPath();
Rectangle newrect = this.ClientRectangle;
path.AddEllipse(newrect);
this.Region = new Region(path);
}
Build the project and add an inherited form called Form2 into the project.
When I open Form2 in the designer, I see a circular form in the designer.
I should say that this behavior is by design. 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.
This is the reason why I see a circular form when I open Form2 in the
designer.
If you don't like the code to set the Region property of the base form to
be called at design time, you may add a condition "!this.DesignMode" on the
code.
The following is a sample.
private void Form1_Load(object sender, EventArgs e)
{
if (!this.DesignMode)
{
System.Drawing.Drawing2D.GraphicsPath path = new
System.Drawing.Drawing2D.GraphicsPath();
Rectangle newrect = this.ClientRectangle;
path.AddEllipse(newrect);
this.Region = new Region(path);
}
}
Build the project and re-open Form2, you should see a rectangle form in the
designer.
Hope this helps.
If you have any question, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
.
- 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
- Designer doesn't update the window/form region based on subclassing
- Prev by Date: Re: Painting in non-client area using c#
- Next by Date: ScrollBars and UserControl
- Previous by thread: 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
|