Docsity

Dialog Boxes: Understanding OpenFileDialog, SaveFileDialog, and FolderBrowserDialog in C#, Slides of C Sharp Programming

Partial preview of the text

Download Dialog Boxes: Understanding OpenFileDialog, SaveFileDialog, and FolderBrowserDialog in C# and more Slides C Sharp Programming in PDF only on Docsity!

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  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

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

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

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

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

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

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