Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Design Time / January 2006

Tip: Looking for answers? Try searching our database.

Newbie needs help with designer and a custom user control.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rich - 24 Nov 2005 00:59 GMT
Hello,

I posted this in another group and was directed here to post the quesiton.
Seems that there are some smart folks here that can answer this...Here is
the post.  Any help would be appreciated.

I have recently started developing Windows Forms from the web and am trying
to do create a control that can be reused. Here is the general gist of it.

I created a new User Control and then proceeded to place a series of panels
on the control. The panels are all docked top. I have another Control that
serves as the base for all our views. I try to drag the control I just created
with the panels onto the base view user control and then try to add a button
to one of the panels in the control. The problem is that i can not get the
panels to allow me to drop a button in them. The panels are marked public
so that should not be an issue, it sems to be related to the designer since
I can add controls in the code behind of base view control.

My questions are this, is there anythign I can do in the control I created
with the panels to allow me to add buttons to them when I use the control
in another usercontrol.

Any help would be appreciated, and I can post the code if needbe. I am sure
that this is not the first time someone has encountered this problem so your
workarounds are appreciated.

Respectfully,

Rich
"Jeffrey Tan[MSFT]" - 24 Nov 2005 01:59 GMT
Hi Rich,

Thanks for your post.

Based on my understanding, you want to expose an inner Panel control in the
UserControl level, so that in Form/UserControl designer, we can directly
drop another control onto this inner panel, and IDE will generate code to
add this control into Panel.Controls collection. If I misunderstand you,
please feel free to tell me, thanks

Yes, this is a design-time limitation of VS.net2003, which has finally been
added in VS2005.
In VS2005, winform designer released INestedContainer interface, which
encapsulate this function. We can just  create a new ControlDesigner, then
in its Initialize method, use ControlDesigner.EnableDesignMode to enable
this inner Panel control's design mode function.

Sample code listed below:
public class MyPanelControlDesigner: ControlDesigner
{
   public override void Initialize(IComponent c)
   {
       base.Initialize(c);
       UserControl1 ctl = (UserControl1)c;
       EnableDesignMode(ctl.MyPanel, "MyPanel");
   }
}

[Designer(typeof(MyPanelControlDesigner))]
partial class UserControl1
{
   
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    public System.Windows.Forms.Panel MyPanel
    {
        get
        {
            return this.panel1;
        }
        set
        {
            this.panel1=value;
        }
    }
}
This works well on my side. Hope it helps

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Rich - 24 Nov 2005 18:33 GMT
Hello Jeffrey Tan[MSFT],

You're the man.  This is exactly what I was hoping for.  I will implement
this and let you know if I run into any issues.

> Hi Rich,
>
[quoted text clipped - 48 lines]
> This posting is provided "as is" with no warranties and confers no
> rights.
"Jeffrey Tan[MSFT]" - 25 Nov 2005 03:22 GMT
You are welcome. If you have further issue, please feel free to post. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Rich - 25 Nov 2005 19:22 GMT
Hello Jeffrey Tan[MSFT],

Everything worked as described.  Just one follow-up.  A reference to System.Design
needs to be made in order for the ControlDesigner class to be recognized
in the System.Windows.Forms.Design namespace.  Just thought I would add to
this thread to save everyone else a few minutes.

Rich

> You are welcome. If you have further issue, please feel free to post.
> Thanks
[quoted text clipped - 5 lines]
> This posting is provided "as is" with no warranties and confers no
> rights
"Jeffrey Tan[MSFT]" - 28 Nov 2005 03:50 GMT
Hi Rich,

Thanks for your sharing.

Yes, normally, when we want to use a class, we can search it in MSDN, then
in the bottom of the class reference, MSDN will list the assembly
containing the class and the namespace it resides in.

Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

The_Assimilator - 10 Jan 2006 12:14 GMT
Another important fact is that the ControlDesigner.EnableDesignMode()
method is only available with .NET 2.0 - it took me a few frustrating
hours to figure this out ;/.
"Jeffrey Tan[MSFT]" - 25 Nov 2005 03:22 GMT
You are welcome. If you have further issue, please feel free to post. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.