GUI HandfdgdOut
GUI HandfdgdOut
1 Introduction
Objects that can display information on the screen or enable users to interact with an
application
Implements IComponent interface
Cont.
Form Properties
Property
Description
Size
Location
Text
AutoScaleDimensions
BackColor
ForeColor
ClientSize
Controls
DPI resolution of display it was built for. Will be scaled to look correct
on other displays.
Background color
WindowState
MinimumSize
DefaultSize
MaximumSize
Form Events
Event
Description
Load
Closing
Closed
Shown
ResizeBegin
ResizeEnd
Form Methods
Method
Description
Activate
Close
Show
BringToFront
Hide
Focus
CheckBoxes
Labeled boxes which can be checked or unchecked
GroupBox
Displays a border around a group of controls
Can have optional label controlled by Text property
Controls can be added by
Placing them within the group box in the designer
Adding to the Controls list programmatically
Panels
A panel is like a group box but does not have a text label
It contains a group of controls just like group box
BorderStyle get/set border style as
BorderStyle.Fixed3D
BorderStyle.FixedSingle
BorderStyle.None
Radio Buttons
Radio buttons are similar to checkboxes, but
10
Radio Buttons
11
TextBox
12
TextBox
13
File Dialog
The file dialog allows you to navigate through directories and load
or save files
This is an abstract class and you use
OpenFileDialog
SaveFileDialog
You should create the dialog once and reuse it so that it will
remember the last directory the user had navigated to
14
File Dialog
15
File Dialog
FileName the name of the file selected
ShowDialog a method to show the dialog and block until cancel or
OK is clicked
if (openDialog.ShowDialog() == DialogResult.OK) {
Image img = Image.FromFile(openDialog.FileName);
pictureBox1.Image = img;
}
16
Image Class
17
PictureBox Class
Normal
StretchImage
AutoSize
CenterImage
Zoom
18
ToolTips
These are the small pop-up boxes which explain the purpose of a
control
To use
Create a new tooltip in the designer
Drop the tooltip onto the form
The tooltip will appear on a tray below the form
19
ToolTips
20
ToolTips
After the tooltip appears in the tray, a new tooltip property appears
for every component
This can be assigned different text for each component
That text will be displayed when the mouse hovers over that
component
21
NumericUpDown
This allows the selection of an integer from a limited range
Also called a spinner
22
MonthCalendar
A control which displays a calendar for the selection
of a range of dates
MinDate the first selectable date
MaxDate the last selectable date
SelectionStart DateTime of start of selection
SelectionEnd DateTime of end of selection
DateChanged event raised when date is changed
GUI (HU 2015/16)
23
DateTimePicker
Properties/methods
24
System.DateTime Structure
A structure representing a date and time
Constructors
Properties
25
DateTime
26
DateTime
DayOfWeek get enumeration of Sunday, Monday,
DayOfYear day of year from 1 366
Methods
DateTime
DateTime
DateTime
DateTime
DateTime
DateTime
AddYears(double value)
AddMonths(double value)
AddDays(double value)
AddHours(double value)
AddSeconds(double value)
AddMilliseconds(double value)
GUI (HU 2015/16)
27
DateTime
TimeSpan Subtract(DateTime)
int CompareTo(DateTime)
static DateTime Parse(string)
ToLongDateString()
ToShortDateString()
ToLongTimeString()
ToShortTimeString()
28
ListBox
29
ListBox
None no selection
One single selection
MultiSimple each click selects additional item
MultiExtended uses shift and control keys
30
ListBox
31
Populating a ListBox
32
ComboBox
A combo box is like a list but lets you displays a selected value.
The list pulls down when a selection is being made.
Options allow the selected text to be editable or to require it to be
selected from the drop-down list
33
ComboBox
DropDownStyle
34
ComboBox
35
Code-behind
36