.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Articles >> C# >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Create User control with using of Enumaration in C#.net

Posted By:Narayanan       Posted Date: February 03, 2012    Points: 200    Category: C#    URL: http://www.dotnetspark.com  

Today, we will discuss about the create and use of user control in C#.net. User control: It is a wonderful control in the .Net Application. It is very useful to create an Application side. It is mainly use to ERP Product. .I thinks, it is more flexible and faster than windows. Programmers must know the Creation of User control. Now, I will explain the Step by Step Procedure to create and use of User control with screen Chart.

Step: 1

  • Create a Project.
  • Select "Class Library" in the Project Template.
  • Give a name of the Class library and Right Click on the solution Explore.
  • Select a User control in the Template.
  • Drag the Text Box form the Tool Box.
  • Drop into User control design screen.
  • Go to View Code (Right click on the design screen and Click View Code in the Context Menu).
Step: 2
         Two questions are raised when I create a User control.
  •    Create Property
  •    Create Events.
 Now, I answer a First Question. Next class we will discuss about the Creation of Events

Create Property:
           Syntax for create Property for User control:
   Public datatype
get { return  datatypevalue;}
set{ datatypevalue = value;}

 What is mean by get and Set?
    Get (get) -- return a Value
    Set (set) -- give a value

       #region Members Declaration
        public bool clr;
        public test tst;
        #endregion Members Declaration

        #region Create Property
        public test  validate
            get { return tst; }
            set { tst = value; }
        #endregion Create Property

        #region Declare Enumaration
        public enum test
        #endregion Declare Enumaration

        #region Create Property
        public bool Colorchk
            get { return clr; }
            set { clr = value; }
        #endregion Create Property

        #region set background
        public void SetColor()
            if (validate == test.Low)
                textBox1.BackColor = System.Drawing.Color.Yellow;
            else if (validate == test.Medium )
                textBox1.BackColor = System.Drawing.Color.Green;
            else if (validate == test.High)
                textBox1.BackColor = System.Drawing.Color.Red;
        #endregion set background

        private void UC_Txt_Load(object sender, EventArgs e)
    Create a windows Application and Call the user control.
        How to call the User control (dll) file in the windows Application?
                Right click on the Tool Box >>Choose Items >> Click "Browse" in the window and Select your dll file location and click "Ok".

Drag your user control and Drop into the form. User and Programmer could view the Validate Property in the Property window of User control.
            User could choice the validate Option and run the Project. See the difference.

    So today we discussed about  the Create and use of User control in C#.net.Thanks for seeing this article.


 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend