Académique Documents
Professionnel Documents
Culture Documents
Transcript I'm Kathleen McGrath, and in this presentation, you're going to learn how to create a Windows Forms application using Visual C# Express. You can use Windows Forms to create UI components like dialog boxes, menus, buttons, and many other controls, that make up a standard Windows application user interface. In this demo, you will learn how to create your own Web browser application, which you can customize with shortcuts to your favorite Web sites.
To populate the menu, you can type in the box that reads "Type Here". I'll type in "Navigate" and press ENTER. More boxes are displayed. In the lower box, I'll type "Home" and press ENTER. I'll add "Go Forward" and "Go Back". These menu items form your basic Web site navigation controls. Now I'll add some additional controls to the form. In the Toolbox, I'll expand Common Controls, and drag a Button to the middle of my form under the MenuStrip. I'll change the Text property to "Go" (this is what you see on the form), and the Name property to "goButton" (this is what you call the button in your code). Next, I'll add a ComboBox control, and in the Properties window, I'll select the Items property, and click the ellipsis button (...) next to the word "(Collection)". This will let me add contents to the ComboBox. So I'll add a couple of Web site addresses. You can add as many as you like, but for this demo, I'll just add a few. Ill start each with http:// and then Ill add: http://www.msn.com http://www.microsoft.com And then finally: http://www.hotmail.com Next, I'll add a WebBrowser control to the formand I'll resize it to fit inside the Windows Form without obscuring the ComboBox and Button controls. If the WebBrowser control doesn't resize easily, first set it to the desired size, open its properties. Setting the Anchor settings to Top, Bottom, Left, Right will cause the WebBrowser control to resize correctly when you resize the application window. Now that I've designed the application, I can start adding some code to provide the program's functionality. The program must have event handlers for the button and for each menu option. An event handler is a chunk of code that runs when a specific event happens on the form, like when the user clicks a buttonthere's one chunk of code (called a method) that handles that event. Visual C# Express creates an empty event handler for you automatically when you double-click the button.
of the ComboBox to the navigate method of the WebBrowser control. So I'll type