Navigating the Object Inspector

The Object Inspector (see Figure 5.12) holds properties for components selected in a visual designer. Each property has a custom editor. When you open the custom editor and change a value, the changes are propagated to the underlying code automatically.

Figure 5.12. The Object Inspector.

graphics/05fig12.jpg

The Object Inspector is blank until a project that uses a design surface is open. To see the Object Inspector, similar to Figure 5.11, create a new project by choosing File, New, Other. When the New Item dialog appears, select the C# Projects folder in the Item Categories list and open an Application project. This will create a Windows Forms application.

Properties in the Object Inspector can be modified in-place or exposed in a dialog for editing, depending on the individual property. When first viewing the Object Inspector, you should see a two-column grid with property names on the left, which I'll call the property column, and their values on the right, which I will call the value column. There is a gutter on the left side of the Object Inspector where you can see which property is selected and expand or collapse properties as needed. When modifying a property, click the mouse anywhere on the row of the property you want to change. The value column will change depending on the property's type. For example, a text property will have an editable text box that you can type in. Properties with a limited set of values, such as those that are enum types, will show a drop-down list that you can open to select a value. If the value column displays a button with ellipses, clicking the button will open a dialog box, which would be specific to that particular property. After changing the value of a property, move the focus off the value column to make the change take effect. You can click on the property column, press the Enter key, or click anywhere else on the screen to make the change take effect.

To see how this works, locate the Text property in the Appearance section of the Object Inspector for the Application project just created. If you click on the editing portion on the right, you can change the value in-place, which will change the title of the form in the designer. Selecting the BackColor property in the Appearance section of the Object Inspector will reveal a drop-down list with tabs available for selecting different color options. Clicking the ellipsis button on the Font property will open a Font dialog.

The other tab of the Object Inspector is for events. This is the GUI interface to hooking up events with methods. The delegate will be connected automatically behind the scenes. Connecting delegates, events, and methods is as easy as either typing the name of an existing method for a given event or just double-clicking the value column of the event name and letting the IDE do all the work for you. Either way, this tab is very handy and I'll be discussing it several times throughout the rest of this book.



C# Builder KickStart
C# Builder KickStart
ISBN: 672325896
EAN: N/A
Year: 2003
Pages: 165

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net