Click here to Skip to main content
Licence 
First Posted 17 Jun 2006
Views 18,544
Bookmarked 9 times

Adding New Properties to a Windows

By | 17 Jun 2006 | Article
Adding New Properties to a Windows

check just Form4 , Form5 in this sourse file

Sample Image - AddNewPropToWinForm.jpg

Introduction

Adding New Properties to a Windows Form

  1. In the Solution Explorer rightclick the project name and select Add, Add Windows Form from the context menu. Name the new form FormName
  2. Right-click anywhere on the form and select View Code from the context menu. In the  view, insert the following code just after the Windows Form Designer Generated Code region: 

  1. //define constant values for State
    public enum State{Idle, Connecting, Processing}
    //use this field as storage location
    //for FormState property
    private State formState;
    //set attributes for FormState property
    [Browsable(true),
    EditorBrowsable(EditorBrowsableState.Never),
    Description(“Sets the custom Form state”),
    Category(“Custom”)]
    //Creating FormState property
    public State FormState
    {
    get
    {
    return formState;
    }
    set
    {
    formState = value;
    switch (formState)<FONT face=MacUSADigital-Regular size=1>
    {
    case State.Idle:
    this.BackColor = Color.Red;
    this.Text = “Idle”;
    break;
    case State.Connecting:
    this.BackColor = Color.Orange;
    this.Text = “Connecting...”;
    break;
    case State.Processing:
    this.BackColor = Color.Green;
    this.Text = “Processing”;
    break;
    }
    }
    </FONT>}</FONT></FONT></FONT></FONT><FONT face=AGaramond-Regular size=3><FONT face=MacUSADigital-Regular size=1><FONT face=MacUSADigital-Regular size=1>
  2. ATTRIBUTES THAT CONTROL THE BEHAVIOR OF A PROPERTY

    Sample screenshot

 

  1. Browsable Indicates whether the property is displayed in the Properties window. Its default value is true.

    EditorBrowsable Indicates whether the property should appear in the

    IntelliSense list of an object in the code view. Its value is of

    the EditorBrowsableState enumeration type, with three

    possible values—Advanced, Always, and Never. Its default

    value is Always, which means “always list this property.” If

    you change the value to Never, the property is hidden from

    the IntelliSense feature.

    Description Specifies a description string for the property. When the

    Description property is specified, it is displayed in the

    description area of the Properties window when the property

    is selected.

    Category Specifies the category of the property. The category is used in

    the Properties window to categorize the property list.

Sample screenshot

Sample screenshot

 

  1. In the Solution Explorer rightclick
  2. the project name and select Add, Add Inherited
  3. Form from the context menu. Name the new form
  4. anyname  make it inherted form the previous form
  5. check the prperty window ...  the custom category & the Formstate new property

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Ledo_moon

Software Developer (Senior)
Areny.Net
Egypt Egypt

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionHow to assign List property to control?? Pinmembergunijan_rakesh23:09 25 Jul '07  
GeneralPerfect PinmemberTodd Wilder14:25 6 Aug '06  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 17 Jun 2006
Article Copyright 2006 by Ledo_moon
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid