740 likes | 857 Views
Week 3: WINDOWS PROGRAMMING. Chapter 15 in “Beginning Visual C# 2010” ebook Chapter 4 in “”MCTS_Self-Paced_Training_Kit” ebook. 4. GroupBoxes and Panels. Arrange components on a GUI GroupBox es can display a caption Text property determines its caption Panel s can have scrollbar
E N D
Week 3: WINDOWS PROGRAMMING Chapter 15 in “Beginning Visual C# 2010” ebook Chapter 4 in “”MCTS_Self-Paced_Training_Kit” ebook
4. GroupBoxes and Panels • Arrange components on a GUI • GroupBoxes can display a caption • Text property determines its caption • Panels can have scrollbar • View additional controls inside the Panel Group Group Windows Programming 1 Chapter 15:Basic Windows Programming Slide 2
GroupBoxes and Panels Windows Programming 1 Chapter 15:Basic Windows Programming Slide 3
GroupBoxes and Panels Windows Programming 1 Chapter 15:Basic Windows Programming Slide 4
GroupBoxes and Panels Controls inside panel panel panel scrollbars Fig. 12.21 Creating a Panel with scrollbars. Windows Programming 1 Chapter 15:Basic Windows Programming Slide 5
GroupBoxes and Panels Chapter 15:Basic Windows Programming
The FlowLayoutPanel Control The FlowLayoutPanel control is a subclass of the Panel control Unlike the Panel control, however, the FlowLayoutPanel dynamically repositions the controls it hosts when it is resized at either design time or run time Like the Panel control, the FlowLayoutPanel control is scrollable Windows Programming 1 Chapter 15:Basic Windows Programming Slide 7
The FlowLayoutPanel Control Windows Programming 1 Chapter 15:Basic Windows Programming Slide 8
The SplitContainer Control The SplitContainer control creates a subsection of the form where Splitter divides SplitContainer into two SplitterPanel controls that function similarly to Panel controls. The SplitContainer.Dock property is set to Fill by default. SplitContainer exposes its two child SplitterPanel controls through its Panel1 and Panel2 properties Windows Programming 1 Chapter 15:Basic Windows Programming Slide 9
The SplitContainer Control Windows Programming 1 Chapter 15:Basic Windows Programming Slide 10
Dialog Boxes (dlg prefix) • Predefined standard dialog boxes for: • File Open and Saving • Printing and Previewing • Color selection • Font selection • Add the Common Dialog control to form • Appears in the Component Tray, pane at bottom of Form Designer where nondisplay controls are shown Windows Programming 1 Chapter 15:Basic Windows Programming Slide 11
Drag common dialog to form Windows Programming 1 Chapter 15:Basic Windows Programming Slide 12
Common Dialog Controls • OpenFileDialog • SaveFileDialog • FontDialog • ColorDialog • PrintDialog • PrintPreviewDialog Windows Programming 1 Chapter 15:Basic Windows Programming Slide 13
FontDialog Windows Programming 1 Chapter 15:Basic Windows Programming Slide 14
FontDialog • Property Font: Gets or sets the selected font. • Property ShowEffects whether the dialog box contains controls that allow the user to specify strikethrough, underline,Color. • Property Color: Gets or sets the selected font color • Method Showdialog(): Windows Programming 1 Chapter 15:Basic Windows Programming Slide 15
ColorDialog Windows Programming 1 Chapter 15:Basic Windows Programming Slide 16
ColorDialog Property Color : get/set color select by the user Property FullOpen: True/false, whether the controls used to create custom colors are visible when the dialog box is opened Method Showdialog():Displays a dialog box user interface Windows Programming 1 Chapter 15:Basic Windows Programming Slide 17
ColorDialog colorDialog1.FullOpen=true; colorDialog1.Color = Color.Red; colorDialog1.ShowDialog(); lblDisplay.ForeColor = colorDialog1.Color; Windows Programming 1 Chapter 15:Basic Windows Programming Slide 18
OpenFileDialog - SaveFileDialog • Property FileName: Gets or sets a string containing the file name selected in the file dialog box. • Property Filter which determines the choices that appear in the "Save as file type" or "Files of type" box in the dialog box. • Property FilterIndex: Gets or sets the index of the filter currently selected in the file dialog box. • Property InitialDirectory: Gets or sets the initial directory displayed by the file dialog box. • Property Title: Gets or sets the file dialog box title. • Method Showdialog(): Windows Programming 1 Chapter 15:Basic Windows Programming Slide 19
The Button, CheckBox, andRadioButton Controls • Button • Text • Click (event) • CheckBox • Checked • CheckState • ThreeState • CheckedChanged (Event) • RadioButton • Checked • CheckedChanged (Event) Radio Check box Windows Programming 1 Chapter 15:Basic Windows Programming Slide 20
The ListBox Control The ListBox control is the simplest of the list-based controls and serves primarily to display a simple list of items in an easy-to-navigate user interface from which users can select one or more items Windows Programming 1 Chapter 15:Basic Windows Programming Slide 21
The ListBox and ComboBox Control • ListBox tool • lst prefix • Simple List Box with/without scroll bars • ComboBox tool • cbo prefix • List may allow for user to add new items • List may "drop down" to display items in Windows Programming 1 Chapter 15:Basic Windows Programming Slide 22
Dropdown Combo Box Simple Combo Box List Boxes Dropdown List Box The ListBox and ComboBox Control Windows Programming 1 Chapter 15:Basic Windows Programming Slide 23
The ListBox Control Windows Programming 1 Chapter 15:Basic Windows Programming Slide 24
Common ListBox Methods Windows Programming 1 Chapter 15:Basic Windows Programming Slide 25
The ListBox, CheckedListBox, andComboBox Controls method a. <MyListBox>.Items.Add(“MyListItem”) lstMyListBox.Items.Add(“cat”); b. <MyListBox>.Items.RemoveAt(Index) lstMyListBox.Items.RemoveAt(3); c. <MyListBox>.Items.Remove(String) lstMyListbox.Item.Remove(“cat”); d. <MyListBox>.Items.Clear() lstMyListBox.Clear(); e. <MyListBox>.SetSelect(index, True/Fale) lstMyListBox.SetSelect(3,True); e. <MyListBox>.ClearSelect() Windows Programming 1 Chapter 15:Basic Windows Programming Slide 26
ComboBox Control The ComboBox control is similar to the ListBox control, but, in addition to allowing the user to select items from a list, it provides a space for a user to type an entry. Additionally, you can configure the ComboBox to either display a list of options or to provide a drop-down list of options Windows Programming 1 Chapter 15:Basic Windows Programming Slide 27
ComboBox Control Windows Programming 1 Chapter 15:Basic Windows Programming Slide 28
The CheckedListBox Controls • CheckedListBox displays a list of items to users and allows them to select multiple items by checking boxes that are displayed next to the items. • Any number of items can be checked, but only one item can be selected at a time. • You can retrieve a collection that represents the checked items by accessing the CheckedItems collection Windows Programming 1 Chapter 15:Basic Windows Programming Slide 29
The CheckedListBox Controls Windows Programming 1 Chapter 15:Basic Windows Programming Slide 30
TheDomainUpDown and NumericUpDown Controls • DomainUpDown (dud) • Items • ReadOnly • SelectedIndex • SelectedItem • Sorted • SelectedItemChanged (Event) Windows Programming 1 Chapter 15:Basic Windows Programming Slide 31
The DomainUpDown and NumericUpDown Controls • NumericUpDown (nud) • Increment • Maximum • Minimum • Value • ValueChanged Event Windows Programming 1 Chapter 15:Basic Windows Programming Slide 32
The MonthCalendar andDateTimePicker Controls Windows Programming 1 Chapter 15:Basic Windows Programming Slide 33
MonthCalendar properties and an event Windows Programming 1 Chapter 15:Basic Windows Programming Slide 34
DateTimePicker Control The DateTimePicker control enables the user to set a date, a time, or both in an easy-tounderstand graphical interface similar to a ComboBox control Windows Programming 1 Chapter 15:Basic Windows Programming Slide 35
DateTimePicker properties and an event Windows Programming 1 Chapter 15:Basic Windows Programming Slide 36
The Timer, TrackBar, andProgressBar Controls • The Timer _ tmr • Enabled Property • Interval Property • Start() Method • Stop() Method • Tick Event Windows Programming 1 Chapter 15:Basic Windows Programming Slide 37
The TrackBar Controls The TrackBar control provides a simple interface that enables the user to set a value from a predetermined range of values by graphically manipulating a slider with the mouse or keyboard commands. This enables the user to rapidly set a value from a potentially very large range. Windows Programming 1 Chapter 15:Basic Windows Programming Slide 38
The TrackBar Controls Windows Programming 1 Chapter 15:Basic Windows Programming Slide 39
The Timer, TrackBar, andProgressBar Controls • ProgressBar (prg) • Maximum Property (100) • Minimum Property (0) • Value Property (0) Windows Programming 1 Chapter 15:Basic Windows Programming Slide 40
The TabControl The TabControl control enables you to group sets of controls in tabs, rather like files in a filing cabinet or dividers in a notebook. TabControl serves as a host for one or more TabPage controls, which themselves contain controls. The user can switch between tab pages (and the controls contained therein) by clicking the tabs on TabControl Windows Programming 1 Chapter 15:Basic Windows Programming Slide 41
The TabControl Windows Programming 1 Chapter 15:Basic Windows Programming Slide 42
ToolTips • We demonstrated tool tipsthe helpful text that appears when the mouse hovers over an item in a GUI Windows Programming 1 Chapter 15:Basic Windows Programming Slide 43
Checked menu item separator bars Menus (mnu prefix) • Menus provide groups of related commands for Windows applications Windows Programming 1 Chapter 15:Basic Windows Programming Slide 44
Menu Design Standards File Menu Edit Menu • New (Ctrl N) • Open (Ctrl O) • Close • Save As • Save (Ctrl S) • Print (Ctrl P) • Exit • Undo (Ctrl Z) • Cut (Ctrl X) • Copy (Ctrl C) • Paste (Ctrl V) • Find (Ctrl F) • Replace (Ctrl H) Windows Programming 1 Chapter 15:Basic Windows Programming Slide 45
The MenuStrip Control The MenuStrip control is essentially a ToolStrip control optimized for the display of ToolStripMenu items. The MenuStrip control derives from ToolStrip and can host all the tool strip items described in the previous lesson. Its primary function, however, is to host ToolStripMenu items. ToolStripMenuItem controls are the controls that provide the visual representation for items on a menu. They can appear as text, an image, or both and can execute code found in their ToolStripMenuItem Windows Programming 1 Chapter 15:Basic Windows Programming Slide 46
The MenuStrip Control Windows Programming 1 Chapter 15:Basic Windows Programming Slide 47
ToolStripMenuItem properties Windows Programming 1 Chapter 15:Basic Windows Programming Slide 48
CREATING MENUS AND MENU ITEMS • To create an access shortcut (or keyboard shortcut), Windows Programming 1 Chapter 15:Basic Windows Programming Slide 49
CREATING MENUS AND MENU ITEMS • To create an access shortcut (or keyboard shortcut), Windows Programming 1 Chapter 15:Basic Windows Programming Slide 50