C# Tutorial - Using the Properties WindowThe Properties Window is used for configuring properties and events on controls in your user interface. Properties specify an object’s attributes, such as the name, text and colour of a control object, without writing code. At the top of the properties window is a drop down listbox which displays the currently selected object or objects. Only objects from the active designer are visible. This allows any component within the designer to be selected. Underneath the drop down listbox are a set of five icons. The first icon sorts the properties into a Categorized view. The categories are accessibility, appearance, behaviour, data, design, focus, layout, miscellaneous and windows style. The second icon sorts the properties into an Alphabetic view. The third icon switches the display to show the properties when the events are viewed. The fourth icon switches the display to show the associated events of the control. The left column of the Properties Window shows the properties of the control (the properties of a form are shown in the next Figure) while the right column displays the associated current value of the property. ![]() Setting a PropertyMost properties contain a number, a string or a value from a drop down list. This makes the developer's job easier as each property will have a default value indicating what type it is. To set a property simply select the right hand box and enter a suitable value. Adding EventsAn event is a message wired to an object that represents something has interacted with the object. The simplest example to think of is when you click on a button within an application. This act causes an event to be raised and handled by the button. The event that is handled is the buttons click event. To see the events that a particular object can handle, click on the lightning bolt button at the top of the Properties Window. ![]() To create an event, simply double-click on the event in the left column. This will create a method to implement the event and open the code window at the appropriate place. If an event already exists, then it can be assigned to the event handler by pulling down the drop-down menu in the right column next to the event that you wish to assign it to.
|