Session 3
Advanced User
Interface Enhancements
WinForms / Session 3 / 2 of 35
Review
The different Controls are grouped into different types
depending on the functionality they offer.
Text Edit Controls allow users to enter and edit text while Text
Display Controls only display text to the user.
Selection list Controls display a set of values to the user and
allow users to select a value from the list.
Graphic storage Controls store graphics, such as images, in it
and Graphic Display Controls are used to display graphics,
such as images.
RichText Controls are text controls that are enriched with extra
functionality that differentiate them from other text controls.
WinForms / Session 3 / 3 of 35
Review Contd…
Value Setting Controls help users to set values, such as
‘yes’ or ‘no’.
Dialog Boxes Controls provide basic functionality like the
Save dialog box, Open dialog box and Print dialog box.
Menu Controls provide the menu functionality to the user
while Commands controls allow users to interact with the
application.
A set of controls can be grouped using Grouping Controls.
The steps involved in calling a form from another form
are:
Create an instance of the form to be called
Show the instance
WinForms / Session 3 / 4 of 35
Objectives
Discuss print support in Winforms
List different types of Dialog Boxes
Work with system defined Dialog Boxes
Implement User Interface Capabilities
Transparent Forms
Control Docking
Control Anchoring
Visual Inheritance
WinForms / Session 3 / 5 of 35
PrintDocument
PrintPreviewControl
Printing Support Controls
WinForms / Session 3 / 6 of 35
Properties
Events
Methods
DefaultPageSettings
DocumentName
PrintController
PrinterSettings
Gettype
Print ToString
BeginPrint
EndPrint
PrintPage
QueryPageSeings
PrintDocument
WinForms / Session 3 / 7 of 35
Properties
M
e
t
h
o
d
s
AutoZoom
Columns
Document
Rows
StartPage
UseAntiAlias Zoom
InvalidatePreview
PrintPreviewControl
WinForms / Session 3 / 8 of 35
Print Support Controls -
Example
PrintPreviewControl
PrintDocument
WinForms / Session 3 / 9 of 35
Dialog Boxes
Uses
Types (by Presentation)
To display information and messages for the
user
To accept user-input
WinForms / Session 3 / 10 of 35
Dialog Types
Types of Dialog (by definition)
Custom Dialog Boxes
Common Dialog Boxes
OpenFileDialog
PageSetUpDialog
FontDialog
ColorDialog
SaveFileDialog
PrintPreviewDialog
PrintDialog
WinForms / Session 3 / 11 of 35
Properti
es
AddExtension
CheckFileExists
CheckPathExists
DefaultExt
FileName
FileNames
Filter
FilterIndex
IntialDirectory
MultiSe
lect
ReadOnlyChecked
RestoreDirectory
ShowHelp
ShowReadOnly
Title
ValidatesNames
OpenFileDialog
WinForms / Session 3 / 12 of 35
Events Methods
OpenFile
ShowDialog FileOk
HelpRequest
OpenFileDialog Contd…
WinForms / Session 3 / 13 of 35
Properti
es
AllowMargins
AllowOrientation
AllowPaper
AllowPrinter
Document
MinMargins PageSeings
PrinterSettings
ShowHelp
ShowNetwork
PageSetUpDialog
WinForms / Session 3 / 14 of 35
Properti
es
Event
AllowScriptChange
AllowSimulations
AllowVectorFonts
AllowVerticalFonts
Color
FixedPitchOnly
Font
FontMust
Exist
MaxSize MinSize
ScriptsOnly
ShowApply
ShowColor
ShowEffect
ShowHelp
Apply
FontDialog
WinForms / Session 3 / 15 of 35
AllowFullOpen
AnyColor Color
CustonColor
FullOpen
ShowHelp
SolidColorOnly
Properti
es
ColorDialog
WinForms / Session 3 / 16 of 35
Properti
es
Method
CreatePrompt
OverwritePrompt
OpenFile
SaveFileDialog
WinForms / Session 3 / 17 of 35
Document
Propert
y
PrintPreviewDialog
WinForms / Session 3 / 18 of 35
Properti
es
Method
AllowPrintToFile
AllowSelection
AllowSomePages
PrintToFile
Reset
PrintDialog
WinForms / Session 3 / 19 of 35
MessageBox
MessageBox
The Code for Showing Messagebox is :-
MessageBox.Show(“[Message]”);
MessageBox.Show method is overloaded in
twelve ways to give more functionality
WinForms / Session 3 / 20 of 35
MessageBox Contd…
Overload
Public static DialogResult Show(string);
Public static DialogResult Show(IWin32Window, string);
Public static DialogResult Show(string, string);
Public static DialogResult Show(IWin32Window, string, string);
public static DialogResult Show(string, string, MessageBoxButtons);
public static DialogResult show(IWin32Window, string string,
MessageBoxButtons);
public static DialogResult Show(string, string, MessageBoxButtons,
MessageBoxIcon);
WinForms / Session 3 / 21 of 35
MessageBox Contd…
Overload
public static DialogResult Show(IWinWindow, string, string, string,
MessageBoxButtons, MessageBoxIcon);
public static dialogResultShow(string, string, MessageBoxButtons,
MessageBoxIcon, MessageBoxDefaultButton);
public static DialogResult Show(IWin32Window, string, string,
MessageBoxButtons, MessageBoxIcon, MessageBoxDefaultButton);
public static DialogResult Show(string, string, MessageBoxButtons,
MessageBoxIcon, MessageBoxDefaultButton, MessageBoxOptions);
public static DialogResult Show(IWin32Window, string, string,
MessageBoxIcon, MessageBoxDefaultButton, MessageBoxOptions);
WinForms / Session 3 / 22 of 35
MessageBox Contd…
The IWin32Window represents the object or
control in front of which the messagebox
would be displayed
MessageBoxButtons
Enumerations that can be displayed on the
messagebox are:
MessageBoxIcon
MessageBoxDefaultButton
MessageBoxOptions
WinForms / Session 3 / 23 of 35
MessageBoxButtons
Member Name
AbortRetryIgnore
OK
OKCancel
RetryCancel
YesNo
YesNoCancel
WinForms / Session 3 / 24 of 35
MessageBoxIcon
Member Name Member Name
Asterisk
Question
Error Stop
Exclamation Warning
Hand
Information
None
WinForms / Session 3 / 25 of 35
MessageBoxDefaultButton
Member Name
Button1
Button2
Button3