April 13th, 2010, 12:39 PM
I wanted to create a custom control in Visual Studio, and then add it as a component to a form. So, I added a new "User Control" to the project, and edited it by dragging and dropping buttons, labels etc. Then, I want to be able to add this control to a form.
I've been told that I needed to build the project, and then add the .dll for the control to the toolbox items. So, I built the project, and then did Tools->Choose Toolbox Items. Here, I browsed through my project directory, and found the .exe for the project, which was found in MyProject\Debug. After this, my user control appeared in the list of toolbox items, with a gear wheel symbol next to it.
So, I then dragged this user control into my Windows form, but the control does not actually appear on the form. It doesn't give me any errors when I drag and drop, but the control is not added to the window, and does not appear in the source code for the form.
So I have done something wrong....one thing I notice is that I added the .exe for the project (MyProject\Debug\MyProject.exe) rather than a .dll for the user control, which is what I was looking for - but couldn't find one anywhere, despite having built the entire project.
Any ideas?? Thanks!
April 27th, 2010, 11:29 PM
Re: User Controls
1. file extension (.exe or .dll) does not metter.
2. As far as I know VS will automatically add all controls you have for tool box after project/solution rebuild. To be able to use control form another project as it was defined simple reference adding and again rebuild should be enough. Your User controls will be in the 'Custom controls' section in the toolbox.
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!