Logo
programming4us
programming4us
programming4us
programming4us
Windows XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
 
programming4us
Windows 7

Visual Studio 2010 : Designing Windows Forms

11/27/2011 11:38:01 AM
The basic building block of a smart client Windows application is the Windows Form. Windows Forms, a key technology of the .NET Framework, provide
  • Libraries for creating a UI

  • Libraries for common tasks, such as reading and writing to the file system

  • A set of controls that provide common UI elements

The Windows Forms Designer is the Visual Studio visual design surface for working with Windows Forms. Use the Windows Forms Designer for these tasks:

  • Visually lay out your UI.

  • Configure UI attributes.

  • Write custom code that's executed when users interact with your form.

Figure 1 displays the Windows Forms Designer in Visual Studio. The next section walks you through creating a new Windows application and using the forms designer.

Figure 1. Use the Windows Forms Designer to lay out your user interface.

1. Creating your first smart client project

Visual Studio uses Solutions and Projects containers to organize all the files necessary to build an application. When you create a new Windows application, Visual Studio creates all the files you need and prepares the development environment with the windows, designers, and editors that you need to work with your new project.

To create a new smart client project in Visual Studio, follow these steps:

  1. Choose File=>New=>Project.

    The New Project window appears.

    You can also open the New Project window by pressing Ctrl+Shift+N. On some editions of the product, you can choose File=>New Project to create a project.


  2. In the Installed Templates hierarchy, click the programming language you want to use.

    A list of project templates that are available for that programming language appears on the right.

    Windows applications created by using Visual Basic, C#, managed C++, and F# use the .NET Framework.

  3. Click the Windows Forms Application icon.

  4. Enter a unique name for your application in the Name text box.

    Although you can give your application any name you want, you probably should choose a name that describes your application. Many developers include the word Windows or the abbreviation Win in an application's name to distinguish it from other kinds of applications, such as Web or mobile applications. In this example, I use the default name WindowsApplication1.

  5. Click OK to create the application.

    Visual Studio creates a new solution with a Windows project. A new Windows Form is added to the project, and Visual Studio displays the form in the Windows Forms Designer.

2. Saying, "Hello world!"

When you create a new Windows application, Visual Studio generates all the code necessary to display the Windows Form on the screen when you run your application. To run your new Windows application, press Ctrl+F5. Visual Studio builds your Windows application and displays a blank Windows Form.

Most Windows applications use menus, text boxes, and buttons. These types of user interface elements are controls. Follow these steps to add controls to make your application say, "Hello world!":

  1. Open the control toolbox by pressing Ctrl+Alt+X.

  2. Make sure that you open the tab named All Windows Forms.

  3. Drag and drop a label control from the toolbox onto the Form Designer.

  4. Drag and drop a button control onto the forms designer.

  5. Double-click the button control.

    Visual Studio creates a block of code to handle the button's Click event. The Code Editor appears with the cursor flashing in the block of code.

  6. Type this line in the Code Editor:

    • VB

      label1.Text = "Hello World!"

    • C#

      label1.Text = "Hello World!";

  7. Press Ctrl+F5 to run your Windows Form.

    When you click the button on your form, Hello World! appears on the label you add in Step 3, as shown in Figure 2.

Figure 2. "Hello World!" appears on the form's label.
Other -----------------
- Troubleshooting and Recovering from Disaster : Using System Restore to Repair Windows
- Microsoft Visio 2010 : Editing Existing Hyperlinks & Adding Multiple Hyperlinks
- Microsoft Visio 2010 : Setting the Hyperlink Base
- Microsoft OneNote 2010 : Finding Tagged Notes, Color-Coding Notebooks, Sections, and Pages
- Microsoft OneNote 2010 : Customizing Tags
- Customizing Microsoft Project 2010 : Creating Custom Fields
- Microsoft Project 2010 : Sharing Data with Others
- Designing a Zero-Touch Deployment (part 2) - Deploying ZTI Task Sequences to Target Computers
- Designing a Zero-Touch Deployment (part 1) - Using System Center Configuration Manager & Creating Task Sequences Using SCCM
- Troubleshooting and Recovering from Disaster : Using the Windows Recovery Environment
 
 
REVIEW
- First look: Apple Watch

- 10 Amazing Tools You Should Be Using with Dropbox

- Sigma 24mm f/1.4 DG HSM Art

- Canon EF11-24mm f/4L USM

- Creative Sound Blaster Roar 2

- Alienware 17 - Dell's Alienware laptops

- Smartwatch : Wellograph

- Xiaomi Redmi 2
programming4us programming4us
 
Popular tags
Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 windows Phone 7 windows Phone 8
programming4us programming4us
Popular keywords
HOW TO Swimlane in Visio Visio sort key Pen and Touch Creating groups in Windows Server Raid in Windows Server Exchange 2010 maintenance Exchange server mail enabled groups Debugging Tools Collaborating
programming4us programming4us
 
programming4us
Women
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone