1 / 14

Windows Form Tour

Windows Form Tour. Looking at our “Getting Started” application. Objectives. Recreate some Module 0 components Picture Data entry box Static text Look at how it has generated the code Make a modification to establish default values for the form. Project Selection. Main IDE Window.

jamesmjones
Download Presentation

Windows Form Tour

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Windows Form Tour Looking at our “Getting Started” application

  2. Objectives • Recreate some Module 0 components • Picture • Data entry box • Static text • Look at how it has generated the code • Make a modification to establish default values for the form

  3. Project Selection

  4. Main IDE Window

  5. Program Code: Main As always, Main() is the entry point for our application…

  6. Form Code: Editable Area • Comments: • partial is used to signify that designer-generated code is in another file • Our form inherits from the .NET Form class • Form1() is our default constructor. If we rename the form, it will automatically be renamed • InitializeComponent(), generated by the designer, is where form elements are created.

  7. Add some elements…

  8. Designer Created Members • Comments: • Yellow highlight show member variables created for our three form elements • Green highlight shows function where we build our form

  9. Designer Generated Constructors • Comments: • Code generated by the designer should not be edited. Is located in Form.Designer.cs • A lot of the code generated involves attaching the blank form to the application—in general, you won’t need to worry about it • Highlighted areas show the three components—the picture, the label and the text box—being constructed. Observe how they look like any other constructors (System.Windows.Forms. are nested namespaces) • Bottom two lines are designed to keep elements from displaying and moving around while they are being initialized

  10. Label and Edit-Box Initialization Comments: These members are all values that can be set in the properties box…

  11. Picture Box Initialization • Comments: • The resources area is a location (in the executable file you are creating) where images, cursors and certain types of text are stored. This increases speed and reduces the need to include separate files when creating an installation (Setup.exe) program. • Everything else is just an editable property

  12. Form Initialization • Comments: • Yellow highlight shows our controls being added to the window. This is necessary so events (e.g., mouse clicks) can be handled by the form, and so they can be removed when the form is closed. • 6F, 13F are 4-byte real numbers (as opposed to 8-byte double values) • Green highlights tell the form it can resume drawing.

  13. Adding default Edit-box Value • Comments: • Creating a member variable was not necessary here • Change control properties only after InitializeComponent(), where they are constructed

  14. Parting words… • When you work in the designer, you are simply generating code—nothing else! • Usually, you won’t have to worry about designer-generated code. It just works! • A little understanding of the designer helps you figure our where customizations go • When you create more complex interfaces, you may start adding controls while the program is running. Use the designer-generated code as your guide!

More Related