Search | Contact | Link To Us  

      VB .NET        

.NET Defined
OOP with VB
VB Language
Win Forms
Windows Controls
ADO .NET
User Controls
File Handling
Multithreading
Deployment
XML Web Services Essential XML
Resources
Discussions
ASP.NET
About



Advertisement


     Home> Windows Controls> Common Dialogs


Common Dialogs

Visual Basic .NET comes with built-in dialog boxes which allow us to create our own File Open, File Save, Font, Color dialogs much like what we see in all other windows applications. To make a dialog box visible at run time we use the dialog box's ShowDialog method. The Dialog Boxes which come with Visual Basic .NET are: OpenFileDialog, SaveFileDialog, FontDialog, ColorDialog, PrintDialog, PrintPreviewDialog and PageSetupDialog. We will be working with OpenFile, SaveFile, Font and Color Dialog's in this section. The return values of all the above said dialog boxes which will determine which selection a user makes are: Abort, Cancel, Ignore, No, None, OK, Return, Retry and Yes.

OpenFileDialog

Open File Dialog's are supported by the OpenFileDialog class and they allow us to select a file to be opened. Below is the image of an OpenFileDialog.

OpenFile Dialog

Properties of the OpenFileDialog are as follows:

AddExtension: Gets/Sets if the dialog box adds extension to file names if the user doesn't supply the extension.
CheckFileEixsts: Checks whether the specified file exists before returning from the dialog.
CheckPathExists: Checks whether the specified path exists before returning from the dialog.
DefaultExt: Allows you to set the default file extension.
FileName: Gets/Sets file name selected in the file dialog box.
FileNames: Gets the file names of all selected files.
Filter: Gets/Sets the current file name filter string, which sets the choices that appear in the "Files of Type" box.
FilterIndex: Gets/Sets the index of the filter selected in the file dialog box.
InitialDirectory: This property allows to set the initial directory which should open when you use the OpenFileDialog.
MultiSelect: This property when set to True allows to select multiple file extensions.
ReadOnlyChecked: Gets/Sets whether the read-only checkbox is checked.
RestoreDirectory: If True, this property restores the original directory before closing.
ShowHelp: Gets/Sets whether the help button should be displayed.
ShowReadOnly: Gets/Sets whether the dialog displays a read-only check box.
Title: This property allows to set a title for the file dialog box.
ValidateNames: This property is used to specify whether the dialog box accepts only valid file names.

SaveFileDialog

Save File Dialog's are supported by the SaveFileDialog class and they allow us to save the file in a specified location. Below is the image of a SaveFileDialog.

SaveFileDialog

Properties of the Save File Dialog are the same as that of the Open File Dialog. Please refer above. Notable property of Save File dialog is the OverwritePromopt property which displays a warning if we choose to save to a name that already exists.

FontDialog

Font Dialog's are supported by the FontDialog Class and they allow us to select a font size, face, style, etc. Below is the image of a FontDialog.

FontDialog

Properties of the FontDialog are as follows:

AllowSimulations: Gets/Sets whether the dialog box allows graphics device interface font simulations.
AllowVectorFonts: Gets/Sets whether the dialog box allows vector fonts.
AllowVerticalFonts: Gets/Sets whether the dialog box displays both vertical and horizontal fonts or only horizontal fonts.
Color: Gets/Sets selected font color.
FixedPitchOnly: Gets/Sets whether the dialog box allows only the selection of fixed-pitch fonts.
Font: Gets/Sets the selected font.
FontMustExist: Gets/Sets whether the dialog box specifies an error condition if the user attempts to select a font or size that doesn't exist.
MaxSize: Gets/Sets the maximum point size the user can select.
MinSize: Gets/Sets the mainimum point size the user can select.
ShowApply: Gets/Sets whether the dialog box contains an apply button.
ShowColors: Gets/Sets whether the dialog box displays the color choice.
ShowEffects: Gets/Sets whether the dialog box contains controls that allow the user to specify to specify strikethrough, underline and text color options.
ShowHelp: Gets/Sets whether the dialog box displays a help button.

ColorDialogs

Color Dialog's are supported by the ColorDialog Class and they allow us to select a color. The image below displays a color dialog.

ColorDialog

Properties of ColorDialog are as follows:

AllowFullOpen: Gets/Sets whether the user can use the dialog box to define custom colors.
AnyColor: Gets/Sets whether thedialog box displays all the available colors in the set of basic colons.
Color: Gets/Sets the color selected by the user.
CustomColors: Gets/Sets the set of custom colors shown in the dialog box.
FullOpen: Gets/Sets whether the controls used to create custom colors are visible when the dialog box is opened.
ShowHelp: Gets/Sets whether the dialog box displays a help button.
SolidColorOnly: Gets/Sets whether the dialog box will restrict users to selecting solid colors only.

Next>> Putting Dialog Boxes to Work

  Privacy Policy | Terms of Use | Site Map | Contact

  © 2004-2010 Startvbdotnet.com. All rights reserved.