Sunday, June 8, 2008

C# Express Edition : Creating Windows Forms User Control

Though there is no project template for User Control in C# Express Edition, it is possible to create User Controls with C# Express edition.

Start C# Express Edition. Start a new Class Library Project by selecting to File, New Project and Class Library from the New Project dialog.



















Go to Solution Explorer and delete the Class1.




























Go to Project menu and Select Add User Control give a good name.





















I am going to have a user control, which on clicking opens by blog in Internet explorer.

An User control is a border canvas. Place a Button Control give appropriate Text and Name to the Button.

In the click event of Button write the following code:





















You can't test an User Control in Express Edition at this point, thought such a feature is provided in Visual Studio.

You have to build the project first, make sure you save the project in an appropriate folder.















Now your control is ready for use.


For Consuming the User control start a new Windows Forms Application Project.
Lets create a new tab in tool box for our controls and give an appropriate name.


























Right click the newly created tab and select Choose Items.
























Choose Toolbox Items dialog will appear. Select Browse. In the Open Dialog navigate to the bin folder of the previously created project, go to debug directory (at the time of deployment the mode should be release) and select the dll.


















The control will appear in the toolbox and you can use the control by adding the control to the form just like ordinary Windows Forms Controls.

3 comments:

  1. Who knows where to download XRumer 5.0 Palladium?
    Help, please. All recommend this program to effectively advertise on the Internet, this is the best program!

    ReplyDelete
  2. Thnx! I need to create a calendar in C# and I'm bored to code the entire user control.

    ReplyDelete
  3. Very good tip on creating custom control in express!
    Thank you!

    ReplyDelete