Windows Forms Panel

Today I was toying with the task of creating an extensible Windows Forms application (much like stock & bond quote systems are today). The client wanted to be able to select a particular real estate investor and have the ability to create any number of more detailed content areas on the main application form.

For example, selecting investor #1 on a Windows form with 6 content areas on it would yield 6 different view of this investor's information.

I thought of using a Windows Forms Panel control. I subclassed it and got everything up and running. Then it came time for me, as one of the developers in my organization, to sit down and design a panel that would provide the user with useful information.

You can't.

I double-clicked on my new class (which subclassed my new "InvestorPanel" Windows Forms control, which in turn subclassed the normal Panel control) and all I got was the component design surface. I wasn't able to precisely lay out labels, text boxes, and other controls on my new control.

Does anyone have an idea of how I can allow developers to visuall design Windows Forms controls in design time so that they don't have to add all their controls at run time?

19 Comments

  • I think in your case it makes more sense to inherit from UserControl instead of Panel so that you can drag and drop some other controls on top of it.

  • I changed the inheritance but I still get the component design surface, not the true WYSIWYG design surface like a form provides.

  • Try adding this



    [System.ComponentModel.DesignerCategory("Form")] at your class definition. See whether it helps.

  • Actually, once I built the solution the design surface appeared, so the UserControl idea worked!



    Thanks,

    Russ

  • Sorry.... it should be



    [DesignerCategory(Category="UserControl")]

    [Designer(DesignerBaseTypeName="System.ComponentModel.Design.IDesigner", DesignerTypeName="System.Windows.Forms.Design.ControlDesigner, System.Design, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]

    [Designer(DesignerBaseTypeName="System.ComponentModel.Design.IRootDesigner, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", DesignerTypeName="System.Windows.Forms.Design.UserControlDocumentDesigner, System.Design, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]

  • Hey...



    Does it work?



    [DesignerCategory(Category="UserControl")]

    public class InvestorPanel : UserControl

    {

    ...

    }

  • Actually, once I built the solution the design surface appeared, so the UserControl idea worked!



    Thanks,

    Russ

  • 378639.. Outstanding :)

  • 378639.. I like it :)


  • I blog frequently and I seriously appreciate your content. This great article has truly peaked my interest. I'm going to take a note of your website and keep checking for new details about once per week. I subscribed to your Feed too.


  • Greetings, I do think your blog could possibly be having browser compatibility problems. Whenever I look at your site in Safari, it looks fine however, if opening in Internet Explorer, it has some overlapping issues. I just wanted to provide you with a quick heads up! Other than that, fantastic blog!


  • I’m impressed, I must say. Seldom do I encounter a blog that’s equally educative and entertaining, and let me tell you, you've hit the nail on the head. The issue is something too few men and women are speaking intelligently about. I'm very happy that I came across this during my search for something relating to this.


  • Having read this I thought it was really informative. I appreciate you spending some time and effort to put this short article together. I once again find myself spending a lot of time both reading and commenting. But so what, it was still worthwhile!


  • An outstanding share! I've just forwarded this onto a colleague who had been conducting a little homework on this. And he in fact bought me lunch because I discovered it for him... lol. So let me reword this.... Thanks for the meal!! But yeah, thanx for spending time to talk about this issue here on your web site.


  • Good post. I will be going through a few of these issues as well..


  • Excellent article. I will be experiencing a few of these issues as well..


  • May I just say what a comfort to uncover a person that actually knows what they are discussing on the net. You certainly understand how to bring an issue to light and make it important. More and more people need to look at this and understand this side of your story. It's surprising you aren't more popular because you most certainly possess the gift.


  • You're so cool! I don't suppose I've read through anything like that before. So good to find somebody with some original thoughts on this issue. Really.. thanks for starting this up. This website is one thing that is required on the internet, someone with a bit of originality!


  • This is a topic that's near to my heart... Cheers! Where are your contact details though?

Comments have been disabled for this content.