1 / 13

Dialog Boxes

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

zaynah
Télécharger la présentation

Dialog Boxes

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Dialog Boxes

  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

  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

  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

  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

  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

  7. Using the SaveFileDialog Control • The SaveFileDialog control works the same way as the OpenFileDialog control • Set the OverwritePrompt property to Trueto prevent the end user from accidentally overwriting files

  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

  9. Using Windows-Defined Directories • Members of the System.Environmentclass 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

  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

  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

  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

More Related