Can't create a User Control

C

Carl Johansson

I'm trying to learn how to create a user control. As far as I can
understand, Visual Studio contains a template named "Windows Control
Library" to this end. However, this template is missing when I open the
"New Project" dialog in Visual C# 2005 Express Edition.

What I can do is add a "User Control" from the "Add New Item" dialog to my
Windows Application project. However, the created user control can only be
placed on forms within the project it was created.

What I want is to add the user control to the Toolbox window permanently for
use in other projects. However, I just can't find the dll file when I browse
for it in the "Choose Toolbox Items" dialog which I open by right clicking
in the Toolbox window.

What I can do is compile the user control generated files using the command
line compiler, but if I include any resources, such as images, I get a very
length error message when I try to place the user control on a form. (Maybe
I use the wrong command line compiler options?, I'm not an expert!)

So, is it possible to create user controls in the C# 2005 Express Edition
version, and if so, how can I go on? I'm stuck!

Any help or hints would be greatly appreciated!

Regards Carl Johansson
 
M

Marc Gravell

So, is it possible to create user controls in the C# 2005 Express Edition

Yes; you simply need to create a dll. The easiest way (to get the
references setup) is to create a new windows forms application, and
then (in the properties dialog) change the output type to library.
Delete the form1 and program.cs that it supplies, and add your own
user-control(s). You should be able to use the IDE to setup your
images/resources etc.

When you've built it, note the file location; close it and start a new
winform app. Now use the toolbox to select items, and browse (on the
[first] .NET tab) to your compiled app. Your controls should appear.
Drop them on your form and you're sorted.

I've just tested this in Express and it worked fine.

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top