locked
How to create user control as generic control RRS feed

  • Question

  • Hi, In my application i have created many user controls. I want to convert one of my control as generic control. So it can be used in other application.

    My user control is a collapsible panel which has two label one is for heading of panel and other is for body.

    I want to make this two label's as property of my control. so when we add this control to another form or user control, the two labels should be appear in property tab.

    So, what is the way to create such type of generic control having custom property.

    Note: C#.net , VS-2008 2.0

    Thanks.

    Friday, April 9, 2010 5:52 AM

Answers


  • write a property that will set label Text as input. Set [Browsable] attribute to true for those properties so that they are shown in Properties pane.

    Showing Label's as property isnt what you should do.. instead set a string property for user control which sets Label's Text.

    This little article is good too ! : http://www.vcskicks.com/custom-properties.php

     


    Thanks

    "Feel the Force !"
    • Marked as answer by Helen Zhou Monday, April 12, 2010 2:56 AM
    Friday, April 9, 2010 6:11 AM

All replies

  • You could create a User Control Library Project to hold all of your usercontrol, then when you create a new proyect you need only to add the reference to the library and you have your controls availables...
    Para el correcto funcionamiento, y que otros usuarios se puedan beneficiar de la solucion de esta pregunta por favor marca las respuestas que te hayan ayudado como "Respuesta".
    Si la respuesta te ha sido util Votala.
    Mi Blog: Jtorrecilla
    Enlace a Faq de Winforms en Ingles Muy bueno
    Friday, April 9, 2010 6:03 AM

  • write a property that will set label Text as input. Set [Browsable] attribute to true for those properties so that they are shown in Properties pane.

    Showing Label's as property isnt what you should do.. instead set a string property for user control which sets Label's Text.

    This little article is good too ! : http://www.vcskicks.com/custom-properties.php

     


    Thanks

    "Feel the Force !"
    • Marked as answer by Helen Zhou Monday, April 12, 2010 2:56 AM
    Friday, April 9, 2010 6:11 AM