programming4us
programming4us
ENTERPRISE

Building Applications with Visual Studio 2010 : Getting Smart about Smart Clients - Using the Properties Window

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

Every control has a set of properties and events that define how the control acts when your application runs. For example, the button control's Text property specifies the text that's displayed on the button. The button control has a Click event that's executed each time a user clicks the button.

The Visual Studio Properties window displays a control's properties and events in a grid, as shown in Figure 1.

Figure 1. Setting a control's properties and events.

The Properties window is open by default. If you close the Properties window at some point, you have two options for opening it again:

  • Choose View=>Properties Window

  • Press F4

The Properties window has the following elements:

  • A drop-down list at the top displays the selected control. Use the list to select a control to view.

  • A toolbar changes the view settings. Your view-setting choices are, from left to right

    • Categorized: Properties appear in groups

    • Alphabetical: Properties are sorted in alphabetical order

    • Properties: The control's properties are displayed

    • Events: The control's events are displayed

  • Two columns display the name-value pairs of the control's properties or events, depending on the view setting.

  • A brief description of the selected property or event appears at the bottom of the window.

The Properties window is a visual tool that organizes and categorizes the thousands of properties and events available for manipulating controls. You use the Properties window for two tasks:

  • Set a control's properties.

  • Create event handlers for a control.

When you use the Properties window, Visual Studio generates the code to set the control's properties and create event handlers. You can do all these tasks by using code, although it's much easier to use Visual Studio.

You can access thousands of properties and events by using the Properties window. Visual Studio groups properties and events into categories so that they're easier to manage. The following list describes the properties and events categories:

  • Action: Creates handlers for events, such as Click and Scroll.

  • Accessibility: Sets properties that make controls accessible to people with disabilities and makes the application easier to use for everyone.

  • Appearance: Contains properties related to font, color, border, and cursor style. The Text property and text-formatting properties are in this group.

  • Behavior: Contains properties and events related to how a control acts. Examples include Sorted, TabStop, and SelectedIndexChanged.

  • Data: Sets a control's data source, gets items selected in a control, and responds to changes in the data.

  • Design: Contains design-time properties, such as whether controls are locked. The Name property is here, too.

  • DragDrop: Responds to events related to dragging and dropping controls.

  • Focus: Captures events related to how the control gains and loses focus.

  • Key: Responds to keyboard-related events.

  • Layout: Sets layout properties, such as anchor, margin, and size.

  • Mouse: Responds to mouse events, such as MouseUp.

  • WindowStyle: Sets properties that define the Windows Form itself.

Within each control are properties that you can set. Here are some common properties that many controls share:

  • Name: Sets the identifier used to reference the control in code.

  • Text: Sets the text displayed in the control.

To set the access key for a control, add an ampersand (&) in front of the letter to use as the access key in the Text property. For example, to set the letter P in Print as the access key, set the Text property for the control equal to &Print. A user can then press the Alt key in combination with the access key to execute the control.


NOTE

Windows Forms are controls. You access the properties of a Windows Forms control the same way you access the properties for any control. Here are the common properties for Windows Forms:

  • Text: Sets the text displayed on the form's title bar.

  • DefaultButton: Sets the button that responds to the Enter key by default.

  • CancelButton: Sets the button that responds to the Esc key by default.

  • MainMenuStrip: Sets the primary menu control for the form.

In addition to the controls you use to customize your forms, you have events to consider. Events are actions that your application might handle or respond to. Examples of common events include

  • Click

  • KeyDown

  • Load

  • ValueChanged

You can get context-sensitive help for any property or event you see in the Properties window by positioning your cursor in the value field for the property or event, and pressing F1.


1. Setting properties

Properties are expressed as name-value pairs. A property's value isn't always as simple as color=black. Values can be complex. You can use the selectors, wizards, and ellipses on the Visual Studio Properties page to dynamically build complex property values.

Examples of complex properties include properties related to

  • Setting data sources

  • Editing collections of items

  • Applying fonts and formatting

  • Selecting images and files

To set properties for a control on a Windows Form, follow these steps:

  1. Click the control in the forms designer.

  2. Press F4 to display the Properties window.

    The control's name and type appear on the drop-down list at the top of the Properties window.

  3. Click the Properties button on the Properties window's toolbar to display a list of the control's properties.

    The Properties button is the third toolbar button from the left.

  4. Scroll down the properties list and enter property values.

    You can type simple property values or select them from a drop-down list. Click the ellipsis button for more complex properties, such as collections to display a dialog box that builds the property, as shown in Figure 2. Click the plus sign (+) next to compound properties to set individual properties.

Figure 2. Click the ellipsis button to build complex properties.

2. Responding to events

The Visual Studio Properties window displays a control's events. For example, when a user clicks a button, the button's Click event occurs. You can use event handlers to write code that fires each time the event fires.

To set an event handler by using the Properties window, follow these steps:

  1. Select a form's control by clicking the control.

  2. In the Properties window, click the Events button to display the control's events.

    To create an event handler by using a default name, either press Enter without typing a name or double-click the field for the name.

    Double-click a control on the Windows Forms Designer to create the control's default event handler.


  3. Type a name for the event handler next to the event and press Enter.

    Visual Studio creates the event handler and opens the code editor to the event handler.

Other  
 
Top 10
Free Mobile And Desktop Apps For Accessing Restricted Websites
MASERATI QUATTROPORTE; DIESEL : Lure of Italian limos
TOYOTA CAMRY 2; 2.5 : Camry now more comely
KIA SORENTO 2.2CRDi : Fuel-sipping slugger
How To Setup, Password Protect & Encrypt Wireless Internet Connection
Emulate And Run iPad Apps On Windows, Mac OS X & Linux With iPadian
Backup & Restore Game Progress From Any Game With SaveGameProgress
Generate A Facebook Timeline Cover Using A Free App
New App for Women ‘Remix’ Offers Fashion Advice & Style Tips
SG50 Ferrari F12berlinetta : Prancing Horse for Lion City's 50th
- Messages forwarded by Outlook rule go nowhere
- Create and Deploy Windows 7 Image
- How do I check to see if my exchange 2003 is an open relay? (not using a open relay tester tool online, but on the console)
- Creating and using an unencrypted cookie in ASP.NET
- Directories
- Poor Performance on Sharepoint 2010 Server
- SBS 2008 ~ The e-mail alias already exists...
- Public to Private IP - DNS Changes
- Send Email from Winform application
- How to create a .mdb file from ms sql server database.......
programming4us programming4us
programming4us
 
 
programming4us