Presentation is loading. Please wait.

Presentation is loading. Please wait.

Michael Olivero Microsoft Student Ambassador for FIU Pick up your free drink below to your left. 1 per person please.

Similar presentations


Presentation on theme: "Michael Olivero Microsoft Student Ambassador for FIU Pick up your free drink below to your left. 1 per person please."— Presentation transcript:

1 Michael Olivero Microsoft Student Ambassador for FIU mike@mike95.com Pick up your free drink below to your left. 1 per person please.

2 Pre-Lecture Topics  Web site resources  Lecture & Materials  http://microsoft.mike95.com  MSDN AA program  http://www.cs.fiu.edu/MSDNAA/  Clarification / Questions from Previous Lecture  “out” parameter  VB.NET vs. C#  Lab #1?

3 Topics Covered Today  Basic User Interface Design Principles .NET Forms  Controls & Components  Menus  Validation  Give Away

4 Basic UI Elements  Forms  Generally contain information or options in order to proceed.  A Form is a class inherited from System.Windows.Forms.Form  Controls  make information and options accessible to users  Some are display only such as labels and picture boxes  Some display and receive input such as text boxes.  Menus  Expose available commands to the users of your application

5 Things to keep in mind when designing  Simplicity  Grouping Related Controls & Default Values  Common mistake: reproducing real world form  Position of controls  Position of Required vs. Optional  Submit below information  Consistency  Forms should follow a pattern

6 .NET Forms After this lesson, you will be able to:  State the role of forms in an application  Explain how to add forms to your application  Explain how to set the start-up form and the start-up location  Explain how to set the visual appearance of your form  Explain how to use form events

7 .NET Forms  Enable interaction between user and application  A way to prompt for or display information without cluttering main UI.  Modal & Non Modal forms.

8 Common Form Methods  Form.Show()  Loads an instance into memory and makes it visible.  Form.ShowDialog()  Same as Show() except must be closed before control returns to main Form.  Form.Activate()  Brings form to the front and gives it focus.  Flashes task bar if app doesn’t have focus.  Form.Hide()  Hides the form from view. Form still is loaded though.  Form.Close()  Removes form from memory and all related resources.

9 Events in Forms  Something interesting happens  Think of it as verbs or actions  Form -> Activated  Form -> VisibleChanged  Form -> Move  You can write custom code for any event.

10 Typical Lifetime Events  Load  Fired when form is loaded into memory  Activate / Deactivate  Fired when form receives focus or looses focus respectively – only among within the current Application.  VisibleChanged  Fired when form is hidden or shown.  Closing  Fired when form is closing  Closed  Fired after form is closed.

11 Demo  Adding forms to a project  Inheriting existing forms  Setting Start-up Form  Startup location attribute  Appearance Settings  Opacity  Show() vs. ShowDialog()  Handling an Event

12 Topics Covered Today Basic User Interface Design Principles Basic User Interface Design Principles.NET Forms.NET Forms  Controls & Components  Menus  Validation  Give Away

13 Controls & Components After this lesson, you will be able to:  Explain the difference between controls and components  Explain how to set the control tab order  Describe which controls can contain other controls and how they are used  Describe docking and anchoring, and explain their use with controls  Describe the process for adding controls to the Toolbox  Describe how to create event handlers for controls  Explain what an extender is and how to use one

14 Controls & Components Are used to enhance functionality of form.  Component vs. Control?  Control has a Visual Interface  Ex. Button  Component has no Visual Interface  Ex. Timer  Components are added to the Components Tray

15 Container Controls Allows you to include other controls within them.  Ex. Group Box, Panel, etc.  You can manipulate all the controls together via the container control  Ex. Container.Visible = false

16 Docking & Anchoring  Specifies behavior of contained controls when form is resized.  Docking  Control is bound to a section of the form: Top, Bottom, Middle, etc.  Anchor  Control is bound by specific distance to edge.

17 Extender Property Components Components which extend the properties of existing components.  Ex. ToolTip & ErrorProvider  Once added to Form, all controls on form have a new property for definition.

18 Demo  Component Tray  Tab Order  Docking / Anchoring  Adding Controls to ToolBox  ErrorProvider Extender Control

19 Topics Covered Today Basic User Interface Design Principles Basic User Interface Design Principles.NET Forms.NET Forms Controls & Components Controls & Components  Menus  Validation  Give Away

20 Using Menus After this lesson, you will be able to:  Describe the process of creating a menu using the MainMenu component  Describe the process of creating a context menu using the ContextMenu ­component  Explain how to enable or disable a menu item  Explain how to create shortcut keys for menu items  Explain how to display a check mark or a radio button on a menu item  Explain how to make menu items invisible  Explain how to dynamically add items to a menu  Explain how to dynamically clone a menu

21 Creating Menus in Design  Use the MainMenu from the toolbox  Create new menus  Set the properties of each menu  Assign event handler to each menu  Hints  To create a separator, use the hyphen  Modify other options through the property window while the menu is selected

22 Creating Menus in Design  Access Key (i.e. ALT-F for File)  Other properties through property window  Checked – displays checkmark next to menu  Radio – displays bullet next to menu

23 Modifying Menus Dynamically Adding Menu Programatically  MenuItem myItem;  myItem = new MenuItem("Item 1", new EventHandler(ClickHandler));  fileMenuItem.MenuItems.Add(myItem); Merging Menus into One  fileMenuItem.MergeMenu(myContextMenu);

24 Context Menus  Special menu that appears as a pop-up menu when the right mouse button is clicked.  Can be created similar to a MainMenu using ContextMenu component.  Can be assigned to any Control via ContextMenu property.  Context menu can be cloned from an existing Menu to avoid duplicating code.  myContextMenu.MenuItems.Add(fileMenuItem.CloneMenu());

25 Things to Know  Menus are like regular controls:  Can make: Visible, Disabled,  You can Merge a menu

26 Demo  Adding Menu  Adding a Context Menu  Reusing a existing Menu for a Context Menu  Handling an Event for a menu

27 Topics Covered Today Basic User Interface Design Principles Basic User Interface Design Principles.NET Forms.NET Forms Controls & Components Controls & Components Menus Menus  Validation  Give Away

28 Validating User Input After this lesson, you will be able to:  Explain the difference between form- level and field-level validation  Direct the focus using control methods and events  Implement form-level validation for your form  Implement field-level validation for your form

29 Form & Field Level Validation  Form Level  Validates all data at once.  Ex. User fills out entire form and clicks Submit. Validation occurs at the moment of submission.  Field Level  Validates as user enters data

30 Common Validation Properties  MaxLength  Maximum length textbox can have.  PasswordChar  The character shown to hide actual password characters  ReadOnly  Cannot make changes to control

31 Common Validation Events  KeyDown, KeyUp, KeyPress Events  Raised when key is pressed.  KeyPress is fired only if key pressed can be represented in by ASCII character.  Ex. ( a-z, A-Z, 0-9, Enter, Backspace )  KeyEventArgs  Parameter passed to Events  Has properties to determine all possible combination of a key event.

32 Typical Validation Event Handler private void textBox1_KeyUp(object sender, KeyEventArgs e) { if (e.Alt == true)MessageBox.Show("The ALT key is down");}

33 Character Validation Char data type can be used to inspect character pressed in KeyPress Event  Char.IsDigit  Char.IsLetter  Char.IsLetterOrDigit  Char.IsPunctuation  Char.IsLower  Char.IsUpper

34 Validating & Validated Events  Validating  Fired before control looses focus.  Validated  Fired after successfully firing Validating  The Validation can be canceled by  e.Cancel = true inside of the handler.

35 Form Level Validation  All fields are validated at once  Simpler than one may expect  Submit Button Event Handler simply checks controls individually or iteratively.  If one fails the check, then can use ErrorProvider and give it focus.

36 Topics Covered Today Basic User Interface Design Principles Basic User Interface Design Principles.NET Forms.NET Forms Controls & Components Controls & Components Menus Menus Validation Validation  Give Away


Download ppt "Michael Olivero Microsoft Student Ambassador for FIU Pick up your free drink below to your left. 1 per person please."

Similar presentations


Ads by Google