Start learning with our library of video tutorials taught by experts. Get started

Visual Studio 2010 Essential Training

Creating a classic Windows application with Windows Forms


From:

Visual Studio 2010 Essential Training

with Walt Ritscher

Video: Creating a classic Windows application with Windows Forms

Forms have been a part of the Microsoft programming lexicon since the first version of Visual Basic appeared back in 1991. Form is the term used to designate an interactive window. .NET is a replacement for those early com-based systems, but Microsoft continues the notion of form-based development. This framework is called Windows Forms. Windows Forms have been extremely popular in corporate applications, forming the basis of thousands of useful applications. They are easy to develop, and within Visual Studio support a drag-and- drop interface designer.
Expand all | Collapse all
  1. 2m 3s
    1. Welcome
      1m 2s
    2. Using the exercise files
      1m 1s
  2. 7m 19s
    1. Understanding the Visual Studio versions
      3m 51s
    2. Setting up your developer computer
      3m 28s
  3. 58m 2s
    1. Creating a Visual Studio project
      4m 58s
    2. Working with Solution Explorer
      6m 32s
    3. Working with big projects
      3m 53s
    4. Taking a tour of the Integrated Developer Environment (IDE)
      8m 36s
    5. Introducing drag-and-drop UI design
      7m 38s
    6. Working with the Properties window
      6m 44s
    7. Looking at Server Explorer
      7m 4s
    8. Exploring the new Help engine
      6m 41s
    9. Setting options for the IDE
      5m 56s
  4. 39m 25s
    1. Creating a simple WPF application
      1m 32s
    2. Building the UI with the editors
      9m 14s
    3. Working with the application code
      3m 37s
    4. Communicating with the web site
      7m 15s
    5. Connecting your data
      8m 4s
    6. Binding to an RSS feed
      5m 4s
    7. Packaging and deploying the application
      4m 39s
  5. 39m 46s
    1. What languages are supported in Visual Studio 2010?
      1m 17s
    2. Exploring basic settings for the Code Editor
      5m 35s
    3. Writing a C# program
      6m 48s
    4. Writing a VB program
      6m 29s
    5. Working with C++
      6m 38s
    6. Working with F Sharp
      6m 9s
    7. Font and color options
      6m 50s
  6. 1h 5m
    1. Formatting your code
      6m 43s
    2. Navigating your code
      7m 44s
    3. Using the Task List
      2m 26s
    4. Commenting your code
      2m 45s
    5. Documenting your code
      8m 26s
    6. Using IntelliSense effectively
      7m 0s
    7. Working with code snippets
      6m 25s
    8. Refactoring your code
      5m 15s
    9. Understanding code generation
      2m 10s
    10. Generating code with T4
      6m 29s
    11. Using the Class View, Class Designer, and Class Diagram tools
      5m 51s
    12. Refactoring VB with CodeRush Xpress
      4m 33s
  7. 1h 11m
    1. Working with project and item templates
      8m 38s
    2. Creating a console application
      7m 5s
    3. Creating a class library
      6m 26s
    4. Creating a web site with ASP.NET
      7m 37s
    5. Creating a rich internet application with Silverlight
      6m 57s
    6. Creating a classic Windows application with Windows Forms
      10m 31s
    7. Creating a dramatic Windows application with Windows Presentation Foundation (WPF)
      4m 41s
    8. Creating a WCF service
      9m 1s
    9. Using an existing WCF service
      6m 38s
    10. Navigation UI designs with the Document Outline view
      3m 41s
  8. 33m 18s
    1. Creating a data project with SQL Project
      6m 24s
    2. Clarifying the confusion on .NET Data
      3m 31s
    3. Using ADO.NET in your application
      6m 50s
    4. Creating typed datasets
      7m 55s
    5. Using the data binding tools
      8m 38s
  9. 30m 13s
    1. Debugging code
      9m 32s
    2. Working with the Watch and other debug windows
      7m 46s
    3. Other debugging techniques
      6m 50s
    4. IntelliTrace historical debugging in Visual Studio Ultimate
      6m 5s
  10. 17m 56s
    1. Understanding Visual Studio editions and test tools
      2m 22s
    2. Verifying your code with unit tests
      8m 58s
    3. Running performance and load tests
      6m 36s
  11. 34m 5s
    1. Building your application
      4m 19s
    2. Customizing the build process with MSBuild
      6m 36s
    3. Setting assembly information
      2m 12s
    4. Deploying a basic Windows application
      2m 19s
    5. Creating an installer with Visual Studio
      7m 39s
    6. Creating a ClickOnce application
      5m 13s
    7. Setting up IIS for deploy
      2m 9s
    8. Deploying a Silverlight or ASP.NET application
      3m 38s
  12. 14m 0s
    1. Understanding source control
      2m 9s
    2. Setting up Team Foundation Server source control
      3m 5s
    3. Using Team Foundation Server source control
      8m 46s
  13. 17m 31s
    1. Understanding the .NET Office integration
      4m 16s
    2. Making a Word 2010 application
      7m 54s
    3. Making an Excel 2010 add-in
      5m 21s
  14. 31m 34s
    1. Understanding the extensibility model in Visual Studio
      2m 17s
    2. Adding external tools to the Tools menu
      4m 42s
    3. Creating macros
      7m 16s
    4. Using the Extension Manager
      5m 1s
    5. Creating an MEF add-in
      7m 9s
    6. Deploying and installing an add-in with VSIX
      5m 9s
  15. 25m 34s
    1. Working with configuration files
      5m 37s
    2. Using the Settings Editor
      7m 30s
    3. Using the Resources Editor
      6m 59s
    4. Localizing your resources
      5m 28s
  16. 1m 17s
    1. Goodbye
      1m 17s

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
Please wait...
Visual Studio 2010 Essential Training
8h 9m Intermediate Nov 16, 2010

Viewers: in countries Watching now:

In Visual Studio 2010 Essential Training, author Walt Ritscher demonstrates how to use Visual Studio 2010 Professional to develop full-featured applications targeting a variety of platforms. Starting with an overview of the integrated developer environment, the course covers working with code editors, navigating and formatting code, and deploying applications. Also included are tutorials on running performance and load tests, and debugging code. Exercise files accompany the course.

Topics include:
  • Creating a Visual Studio project
  • Building the user interface
  • Binding to an RSS feed
  • Coding with IntelliSense
  • Creating rich Internet applications with Silverlight
  • Building Windows applications with Windows Forms
  • Integrating with SQL Server
  • Working with Microsoft Office applications
  • Understanding extensibility in Visual Studio
  • Working with data, ADO.NET and datasets
  • Using source control
Subject:
Developer
Software:
ASP.NET Silverlight Visual Studio
Author:
Walt Ritscher

Creating a classic Windows application with Windows Forms

Forms have been a part of the Microsoft programming lexicon since the first version of Visual Basic appeared back in 1991. Form is the term used to designate an interactive window. .NET is a replacement for those early com-based systems, but Microsoft continues the notion of form-based development. This framework is called Windows Forms. Windows Forms have been extremely popular in corporate applications, forming the basis of thousands of useful applications. They are easy to develop, and within Visual Studio support a drag-and- drop interface designer.

Despite their popularity, WinForm development is on the wane. WinForm uses GDI as it's rendering engine, which some consider inferior for building modern interfaces. Because of this, Microsoft created a replacement technology for Windows Forms. This new UI/API is called Windows Presentation Foundation, and it is covered in the next movie in this chapter. Even though I'm a diehard WPF fan, I want to show you some of the features of Windows Forms. It is a powerful tool, and is still used by many development shops as their leading Windows client development framework.

I'm inside Visual Studio, and I've opened a solution called CreateWindowsForms. Currently, there are no projects within this solution. I am going to right-click on the solution and choose Add > New Project. For today, I'm going to create a Visual Basic template because it has some interesting Windows Forms templates to use. So I am going to choose Visual Basic, and then Windows Form Application, and then I am going to go ahead and leave at its default name of WindowsApplication1 and click OK.

Here is my main screen of my application. I would like to add a couple of more Windows templates. To do that, I'm going to right-click on my WindowsAplication, choose Add > New Item. If I click on the Windows Forms node here, under Common Items, I can see about 20 different form templates. I am going to use the Splash Screen, and I am going to add one more: the Explorer Form.

As you can see, the Explorer Form has a complex UI in place. It has a menu, a toolbar, a split screen and many other features. That's all I want to show in that designer. The Splash Screen is designed and pop up when the application starts. To tell Visual Studio to launch this first and then my main form, I need to go to My Project, double-click here, scroll down to the bottom of this Application section, and choose Splash Screen. Choose your appropriate form.

While I'm in this dialog, I'll also make sure that my start up form is correct. I want to start with Form1 as my main screen. Now, I'm ready to test. Debug > Start Debugging. On my machine, it prompts me if I want to save my changes. There is the Splash Screen, and there is our main UI. I'll click the Close button to shut down this form, and then I'll close these two windows here: the WindowsAplication properties and the SplashScreen.

So, for the next couple of minutes, I'm going to creating some user interface for this screen. I am going to start by dragging a few items to the designer. First comes the menu strip. So I am going to go to my Toolbox. I am going to open this All Windows Forms section and find the MenuStrip control and drag that over. Notice that Visual Studio automatically docks that to the top. I'll also find the StatusStrip and drag that and drop it.

That gets docked along the bottom edge of my screen. I need a ListBox. Here it is. I'll drag that over and make it a little bit wider and taller. And then the last item I want to add is something called the PropertyGrid. Now, you've seen the PropertyGrid inside Visual Studio. It lives over here; at least on a Windows Form Application, it does. This control is also usable in your applications. So I am going to find it. Here it is.

I'll drag that over, and the next step I want to take is to dock this PropertyGrid to the right edge of the screen. To do that, I'm going to go to the Visual Studio property grid, scroll down to the Dock property, select it, and choose this dropdown. This represents the edges of the window where I can dock the control. If I click on this button right here, it means to dock to the right edge.

And I'll make it about 50% of the width of the screen. Now, I am ready to write some code. I need some menu items up here, so I am going to click at the top of the screen. I currently have no menu text. There is a very simple way to add a lot of menu items in a hurry in Visual Studio, by going to this little special icon over here, the black triangle, clicking once and then choose Insert Standard Items. See what happened? It added a File menu, an Edit menu, and the one I'm interested in--the Tools menu.

Now, I am going to add my own menu item right here, so I just click once and start typing. Double-click on this one, and it switches me over to the Visual Studio editor, and it has stubbed in this Visual Basic code. Now, what I want to do is go out to a folder in my hard drive. I am going to go to my Desktop folder, and I am going to search for text files, files that end with a TXT extension. Now, I have already created two empty text files on my Desktop.

If you're following along, make sure that you point your example to a folder that contains some files with a TXT extension. I am going to start by getting my desktop folder. We'll declare a variable called location, and then I'm going to go to the .NET engine, and I'm going to query the Environment, using this method called GetFolderPath. And watch what happens when I hit the open parenthesis--Visual Basic suggests this enumerated value.

I am going to be looking in my Desktop folder. So this is saying to .NET, "Somewhere on my hard drive is a Desktop folder. I don't know the exact location of it. Would you look that up and find the path of that and store that here?" Now next, I want to write a link query to talk to that file system and query the data that's here. Now rather than hand type that, I have an Assets folder here that contains a text local link code. I am going to open up this text file, and then I am going to copy this text and paste it into this code window right here. And I see I have this blue squiggle.

This happens occasionally. It means I am missing an Import statement at the top of my code window. That should fix it. So what this says is I'd like to start a query and store the query in this variable. Go out to the hard drive and walk through all of the files in this folder--remember that's my Desktop folder--and then here is the query part. Do a Where clause on that and say I'm only interested in files if they have a TXT extension on them.

Once you've done that query, I want you to select out the information and store it in this data type called the FileInfo. Now FileInfo contains information like when the file was last saved and what the file name is and things like that. So I am going to select that out. On line 12, I am going to execute the query by calling ToList, which returns the results of the query as a list. I am going to assign them to the list box as data source, and then I am going to tell the list box which property on the FileInfo class I'd like to show. I want to show the Name of the file.

The next piece of information comes from the ListBox. As the items are loaded in the ListBox I am going to click on them, and then I want to take the data, the details about those files, and load them into this PropertyGrid. So I need to write an event procedure for the ListBox. So I'll switch back to my designer, I clicked in the ListBox. I am going to go over to this property grid and click on the lightning bolt, and then I am going to find this property called SelectedIndexChanged. That's an event that fires whenever the user selects a new item in the ListBox.

I'll double-click right here on the edge, right in this column here, and Visual Studio will stub in this code on my behalf. If I go to this text file up here, SelectedIndexChanged.txt file, I've got the code I am going to write in there. So I'll copy that over and then paste it in here. What this code says is, "Make sure that the user has selected something in the ListBox. If they've selected something, then wherever it is they selected assign it to the PropertyGrid.

The PropertyGrid then interrogates that object and shows me all the details about whatever that type is." I think I am ready to run the application. Debug > Start Debugging. Click Tools > Show Files. It found two files on my desktop. And hen I click on the file, it loads the information into the PropertyGrid about that item. For instance, you can see the file name is abc.txt, and the last time it was accessed was at 2:15 this afternoon.

There is lot more I can show you with Windows Forms, but that's about all the time I have in this movie. Remember this: Windows Forms are still a viable technology for developing Windows applications, and they are common in many corporate environments.

Find answers to the most frequently asked questions about Visual Studio 2010 Essential Training.


Expand all | Collapse all
Please wait...
Q: Which edition of Visual Studio 2010 do I need to follow along in this course?
A: The course is taught with Visual Studio 2010 Professional, but can also be used with the Premium or Ultimate editions. The Express editions of Visual Studio, including Visual Basic 2010 Express, Visual C# 2010 Express, and Visual C++ Express, are not covered in this course.
Q: I'm attempting to download the exercise files for this course, and my virus protection is blocking me from unzipping the downloaded file. Are the files corrupted?
A: The alert is a false-positive message. Your antivirus software is detecting the active code included in the exercise files, which in some ways resembles viral code. There is nothing to be alarmed about and you can ignore the warning. This is common among coding courses and environments.
Share a link to this course
Please wait... Please wait...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.
Upgrade now


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Upgrade now

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Visual Studio 2010 Essential Training.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Welcome to the redesigned course page.

We’ve moved some things around, and now you can



Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked