13
Dialog Boxes

Dialog Boxes

  • Upload
    zaynah

  • View
    26

  • Download
    0

Embed Size (px)

DESCRIPTION

Dialog Boxes. The OpenFileDialog and SaveFileDialog Controls. All dialog boxes derive from the CommonDialog class and share similar features The OpenFileDialog and SaveFileDialog controls are derived from the CommonDialog class - PowerPoint PPT Presentation

Citation preview

Page 1: Dialog Boxes

Dialog Boxes

Page 2: Dialog Boxes

Slide 2

The OpenFileDialog and SaveFileDialog Controls All dialog boxes derive from the CommonDialog

class and share similar features The OpenFileDialog and SaveFileDialog

controls are derived from the CommonDialog class These classes allow the end user to select a file

to open or save The FolderBrowserDialog control also derives

from the CommonDialog class This control allows the end user to select a

folder

Page 3: Dialog Boxes

Slide 3

Members of the OpenFileDialog and SaveFileDialog Classes The CheckFileExists and CheckPathExists

properties control whether the end user can select a file or folder that does not exist

The FileName property contains the filename selected by the end user

The Filter property defines the type of files that will be displayed for selection

The FilterIndex property contains the index of the current filter

The Filter and FilterIndex properties work together

Page 4: Dialog Boxes

Slide 4

Members of the OpenFileDialog and SaveFileDialog Classes (continued)

The InitialDirectory property contains the initial folder where the search for files begins

The OverwritePrompt property applies only to the SaveFileDialog. If True, the end user will be prompted before a file is overwritten

The RestoreDirectory property defines whether the current directory will be restored after the end user selects a file

The ShowDialog method displays the respective dialog box

4

Page 5: Dialog Boxes

Slide 5

The Filter Property (introduction) The Filter property restricts the files

displayed based on a file extension A filter consists of

A description Followed by a vertical bar Followed by the actual filter

Multiple filters can be connected together

Do not put spaces between the vertical bars

Page 6: Dialog Boxes

Slide 6

The Filter Property (Example) Set the Filter to three possible filters

(*.txt), (*.rtf), and (*.*) Set the FilterIndex to select the

second filter by default

ofdMain.Filter = "Text files (*.txt)|*.txt|" _ "Rich text files (*.rtf)|*.rtf|All files" _ "(*.*)|*.*"

ofdMain.FilterIndex = 2

Page 7: Dialog Boxes

Slide 7

Using the SaveFileDialog Control The SaveFileDialog control works the

same way as the OpenFileDialog control

Set the OverwritePrompt property to True to prevent the end user from accidentally overwriting files

Page 8: Dialog Boxes

Slide 8

The FolderBrowserDialog (Introduction) Use the FolderBrowserDialog to browse for

folders instead of files Members

The Description property contains the text appearing in the title bar

The RootFolder property contains the topmost folder appearing in the dialog box

The SelectedPath property contains the folder selected by the end user

The ShowDialog method displays the dialog box

Page 9: Dialog Boxes

Slide 9

Using Windows-Defined Directories Members of the System.Environment

class are used to get system directories The SystemDirectory property gets the

Windows system directory The directory is typically C:\Windows\

System32 The CurrentDirectory property contains

the directory from which the application was run

The GetFolderPath method gets a system special folder

Page 10: Dialog Boxes

Slide 10

Color (About) Color is made up of RGB values and an

“alpha” value that controls opacity Values range between 0 and 255 255,255,255 is white 0,0,0 is black

Page 11: Dialog Boxes

Slide 11

The ColorDialog (Introduction) It works the same way as the other

dialog boxes Call ShowDialog to display the dialog box The Color property contains the selected

color Properties

AllowFullOpen allows the user to select custom colors

FullOpen displays the full color palette

Page 12: Dialog Boxes

Slide 12

The FontDialog (Introduction) It works the same way as the other

dialog boxes Call ShowDialog to display the dialog box There are many more properties to work

with ShowApply, ShowColor, ShowEffects

control how the dialog box appears Font gets or sets the desired font MaxSize and MinSize control the

selectable font sizes

Page 13: Dialog Boxes

Slide 13