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

An overview of dialog boxes in c# programming, focusing on the openfiledialog, savefiledialog, and folderbrowserdialog controls. Learn about their features, properties, and usage. Discover how to restrict file types, set initial directories, and prevent file overwriting.

Typology: Slides

2012/2013

Uploaded on 09/27/2013

vikrant
vikrant 🇮🇳

4.4

(9)

119 documents

1 / 12

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Dialog Boxes
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa

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