Article
    C#
    ADO.Net
    .NET
    ASP.Net & Web Forms
    Custom Controls
    Web Development
    Exception Handling
    XML
    Database
    Security in .Net
    Testing
    Web Services
    Windows Services
    Windows Controls
    WCF
    AJAX
    WPF
    XAML
    Reporting
    Setup
    VB.Net
    LINQ
    JQuery
    SilverLight
    JavaScript
    HTML5
    Crystal Report
    Cloud Computing
    Share Point
    Visual C++
    MVC
    Android
    PHP
    Java
    HTML
    WordPress
    Joomla
    Products
    Drupal
    Windows Phone
    JSON
    LightSwitch
    iPhone/iPad
    Ruby on Rails
    IIS 7
    Windows 8
    CSS/CSS3
    Excel
    MS Access
    Shortcut Keys
    Visual SourceSafe
    Team Foundation Server
    API(s)
    Sencha-Touch
Follow Us
Follow _MindStick_ on Twitter View MindStick Software's LinkedIn profile View MindStick Software's Facebook profile
Top Contributor
Advertisement
Advertise with Us
Mindstick
Article Article  Forum Forum  Blog Blog  Quiz Quiz  Beginner Beginner  Careers Careers  Contact Contact  Login Login  
Home | Product | Services | About Us | Interview | DeveloperSection | Submit an Article | Submit Blog

Home >> Windows Controls >> Creating and using Windows Forms Control Library in C#.Net
Creating and using Windows Forms Control Library in C#.Net
Creating and using Windows Forms Control Library in C#.Net


by Haider M Rizvi on 7/29/2010 7:57:59 PM

Views: 18444       Comments: 0

Creating and using Windows Forms Control Library (User Control) in C#.net

Creating user control

 

 

 

 

To create User Control in C# select “Windows Forms Control Library” icon from New Project Dialog Box.

Add some controls and add codes for the controls in User Control.

Example

 

Code

private void btnColour_Click(object sender, EventArgs e)

        {

//this will change the color of form on which this control is placed.

           this.ParentForm.BackColor= Color.Red;

        }

Now once the control is created we need to built it in order to use in other projects.

Using User Control in project

To use user control in our project we need to add that control in project. To add right click on Toolbox and select “Choose Items”

A dialog box “Choose Toolbox Items” will appear. In that dialog box click browse button and select user control created earlier from bin\debug folder of user control project, then press Ok.

User control will be added to the project toolbox.

Now we can use the user control.

 

Example

 

 

 

 

Screen shot after Execution

Color of the form changes on button click without doing any coding in the current form. On button click code of user control is executed.

Report Abuse Form
Reason:    
 

Title :
Comment :
Text ColorBackground Color
BoldItalicUnderline
LeftCenterRightJustify
Ordered ListBulleted List
IndentOutdent
Horizontal Rule
SubscriptSuperscript
HyperlinkImage
Design ModeDesign
View HtmlHtml
     
 
Latest Article by Haider M RizviRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Latest BlogsRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Top Viewed ArticlesRSS Feed
    
    
    
    
    
    
    
    
    
    
Top Viewed BlogsRSS Feed
    
    
    
    
    
    
    
    
    
    
Latest Interview QuestionsRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Total Online Users: 2680
Advertisement
MindStick Cleaner
Advertise with Us
  
Copyright © 2009 - 2013MindStick. All Rights Reserved.