none
Add custom user control into a form RRS feed

  • Question

  • Hi,

    Currently I am using Visual Studio .Net 2005, and attempting to develop my own custom control ( containing few text fields and one checklist  ).

    How could I include this custom control into my main form ? is there any easy way with VS ?

    Thanks for your help, looking forward to get one answer.

    Happy new year Wink

     

    Monday, December 31, 2007 10:53 AM

Answers

  •  

    Hi VinceExtense,

    First, let me check my understanding of your post with you, you want to create custom control and put the control onto the toolbox of Visual Studio 2005 so that you can easily drag and drop the control onto you form, right?

    As far as I know, you have three choices to achieve this.

    Firstly, you can create the custom control in the same project of your application. This will automatically add the control to the toolbox. It is easy to handle, but the disadvantage of this is that you can only drag and drop this control in the same project.

    Secondly, you can create a Class Library project and create your custom control in this Class Library. This will automatically add the control to the toolbox and you can drag and drop this control in the same solution.

    Finally, you can use the Visual Studio Command Prompt to add custom controls to the toolbox. This will make the control always show in the toolbox. Please check the following thread:

    ·         http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2153798&SiteID=1

    Hope this helps.
    Best regards and Happy New Year.
    Rong-Chun Zhang

    Wednesday, January 2, 2008 2:26 AM

All replies

  • The way I have done it is that I put all my user controls into a control library.  The first time I built the control library, I used Windows Explorer to navigate to the DLL and then dragged-and-dropped the DLL into the Tool Box's General tab in the IDE. I also added a reference to the DLL to the project, so that the DLL gets copied into the output directory when the DLL has changed.  Thereafter, every time I add a new control or change the interface to one of the controls, I delete the entries for the control library in the tool box and then drag and drop the DLL into the tool box again.

     

    I have tried to make the user controls part of the project, but I had no luck with that.  BTW, I use C++ exclusively, but the technique above should be generally applicable.

    Monday, December 31, 2007 11:34 PM
  •  

    Hi VinceExtense,

    First, let me check my understanding of your post with you, you want to create custom control and put the control onto the toolbox of Visual Studio 2005 so that you can easily drag and drop the control onto you form, right?

    As far as I know, you have three choices to achieve this.

    Firstly, you can create the custom control in the same project of your application. This will automatically add the control to the toolbox. It is easy to handle, but the disadvantage of this is that you can only drag and drop this control in the same project.

    Secondly, you can create a Class Library project and create your custom control in this Class Library. This will automatically add the control to the toolbox and you can drag and drop this control in the same solution.

    Finally, you can use the Visual Studio Command Prompt to add custom controls to the toolbox. This will make the control always show in the toolbox. Please check the following thread:

    ·         http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2153798&SiteID=1

    Hope this helps.
    Best regards and Happy New Year.
    Rong-Chun Zhang

    Wednesday, January 2, 2008 2:26 AM