<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Rénald's Blog - Visual Studio 2005</title>
    <link>http://www.renaldnollet.com/blog/</link>
    <description />
    <language>en-us</language>
    <copyright>Rénald Nollet</copyright>
    <lastBuildDate>Tue, 13 Nov 2007 17:26:00 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.9074.18820</generator>
    <managingEditor>rno.rno.rno@gmail.com</managingEditor>
    <webMaster>rno.rno.rno@gmail.com</webMaster>
    <item>
      <trackback:ping>http://www.renaldnollet.com/blog/Trackback.aspx?guid=d14beb28-7960-44c3-88d5-fbc0d5fbe30f</trackback:ping>
      <pingback:server>http://www.renaldnollet.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.renaldnollet.com/blog/PermaLink,guid,d14beb28-7960-44c3-88d5-fbc0d5fbe30f.aspx</pingback:target>
      <dc:creator>Rénald Nollet</dc:creator>
      <wfw:comment>http://www.renaldnollet.com/blog/CommentView,guid,d14beb28-7960-44c3-88d5-fbc0d5fbe30f.aspx</wfw:comment>
      <wfw:commentRss>http://www.renaldnollet.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=d14beb28-7960-44c3-88d5-fbc0d5fbe30f</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <span style="color:#333333; font-family:Georgia; font-size:12pt">Maybe you already
met this kind of problems with UserControl and Visual Studio 2005 : you design a main
winform without any problems, you design a user control without any problem. But then
when you add the user control to the main form, the designer will encouter an error
on the main form. You nevertheless may run the application without any problem.</span>
          <span style="font-size:1pt">
          </span>
        </p>
        <p>
          <span style="color:#333333; font-family:Georgia; font-size:12pt">The reason for this
is that the designer is calling the load method of user controls when you open the
form that is hosting those user controls. </span>
        </p>
        <p>
        </p>
        <p>
          <span style="color:#333333; font-family:Georgia; font-size:12pt">A simple test : </span>
        </p>
        <p>
          <span style="color:#333333; font-family:Georgia; font-size:12pt">Here is the designer
part of my user control (an empty one with just one label, this is enough to demonstrate
our problem):<br /><br /><img src="http://www.renaldnollet.com/blog/content/binary/071109_1500_VisualStudi1.jpg" alt="" /></span>
        </p>
        <p>
          <span style="color:#333333; font-family:Georgia; font-size:12pt">
            <br />
Here is the code behind :<br /><br /><img src="http://www.renaldnollet.com/blog/content/binary/071109_1500_VisualStudi2.jpg" alt="" /><br /><br />
The important thing there is the Load method. </span>
        </p>
        <p>
        </p>
        <p>
          <span style="color:#333333; font-family:Georgia; font-size:12pt">Then, if I want to
add the user control to a main empty form, here is what you will see : </span>
        </p>
        <p>
          <img src="http://www.renaldnollet.com/blog/content/binary/071109_1500_VisualStudi3.jpg" alt="" />
          <span style="color:#333333; font-family:Georgia; font-size:12pt">
          </span>
        </p>
        <p>
          <span style="color:#333333; font-family:Georgia; font-size:12pt">Most of the time,
this is not annoying, but sometimes, this may lead to the impossibility to woon the
main form with the designer (because you are in design time and not run time, information
may not be available): </span>
        </p>
        <p>
        </p>
        <p>
          <img src="http://www.renaldnollet.com/blog/content/binary/071109_1500_VisualStudi4.jpg" alt="" />
          <span style="color:#333333; font-family:Georgia; font-size:12pt">
          </span>
        </p>
        <p>
          <span style="color:#333333; font-family:Georgia; font-size:12pt">
            <br />
You can then work with the DesignTime property of the user control : </span>
        </p>
        <p>
        </p>
        <p>
          <img src="http://www.renaldnollet.com/blog/content/binary/071109_1500_VisualStudi5.jpg" alt="" />
          <span style="color:#333333; font-family:Georgia; font-size:12pt">
          </span>
        </p>
        <img width="0" height="0" src="http://www.renaldnollet.com/blog/aggbug.ashx?id=d14beb28-7960-44c3-88d5-fbc0d5fbe30f" />
      </body>
      <title>Visual Studio 2005 and the Load method of UserControl</title>
      <guid isPermaLink="false">http://www.renaldnollet.com/blog/PermaLink,guid,d14beb28-7960-44c3-88d5-fbc0d5fbe30f.aspx</guid>
      <link>http://www.renaldnollet.com/blog/2007/11/13/VisualStudio2005AndTheLoadMethodOfUserControl.aspx</link>
      <pubDate>Tue, 13 Nov 2007 17:26:00 GMT</pubDate>
      <description>&lt;p&gt;
&lt;span style="color:#333333; font-family:Georgia; font-size:12pt"&gt;Maybe you already
met this kind of problems with UserControl and Visual Studio 2005 : you design a main
winform without any problems, you design a user control without any problem. But then
when you add the user control to the main form, the designer will encouter an error
on the main form. You nevertheless may run the application without any problem.&lt;/span&gt;&lt;span style="font-size:1pt"&gt; &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="color:#333333; font-family:Georgia; font-size:12pt"&gt;The reason for this
is that the designer is calling the load method of user controls when you open the
form that is hosting those user controls. &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="color:#333333; font-family:Georgia; font-size:12pt"&gt;A simple test : &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="color:#333333; font-family:Georgia; font-size:12pt"&gt;Here is the designer
part of my user control (an empty one with just one label, this is enough to demonstrate
our problem):&lt;br /&gt;
&lt;br /&gt;
&lt;img src="http://www.renaldnollet.com/blog/content/binary/071109_1500_VisualStudi1.jpg" alt="" /&gt; &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="color:#333333; font-family:Georgia; font-size:12pt"&gt;
&lt;br /&gt;
Here is the code behind :&lt;br /&gt;
&lt;br /&gt;
&lt;img src="http://www.renaldnollet.com/blog/content/binary/071109_1500_VisualStudi2.jpg" alt="" /&gt;
&lt;br /&gt;
&lt;br /&gt;
The important thing there is the Load method. &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="color:#333333; font-family:Georgia; font-size:12pt"&gt;Then, if I want to
add the user control to a main empty form, here is what you will see : &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.renaldnollet.com/blog/content/binary/071109_1500_VisualStudi3.jpg" alt="" /&gt;&lt;span style="color:#333333; font-family:Georgia; font-size:12pt"&gt; &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="color:#333333; font-family:Georgia; font-size:12pt"&gt;Most of the time,
this is not annoying, but sometimes, this may lead to the impossibility to woon the
main form with the designer (because you are in design time and not run time, information
may not be available): &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.renaldnollet.com/blog/content/binary/071109_1500_VisualStudi4.jpg" alt="" /&gt;&lt;span style="color:#333333; font-family:Georgia; font-size:12pt"&gt; &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="color:#333333; font-family:Georgia; font-size:12pt"&gt;
&lt;br /&gt;
You can then work with the DesignTime property of the user control : &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://www.renaldnollet.com/blog/content/binary/071109_1500_VisualStudi5.jpg" alt="" /&gt;&lt;span style="color:#333333; font-family:Georgia; font-size:12pt"&gt; &lt;/span&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.renaldnollet.com/blog/aggbug.ashx?id=d14beb28-7960-44c3-88d5-fbc0d5fbe30f" /&gt;</description>
      <comments>http://www.renaldnollet.com/blog/CommentView,guid,d14beb28-7960-44c3-88d5-fbc0d5fbe30f.aspx</comments>
      <category>.NET 2.0</category>
      <category>Visual Studio 2005</category>
    </item>
  </channel>
</rss>