Exforsys

VB.NET 2005

  1. VB.NET 2005 Free Training
  2. The .NET Framework Architecture Part 1
  3. The .NET Framework Architecture Part 2
  4. Application Class and Message Class
  5. Implementing Class Library Object
  6. Visual Studio.NET Namespaces
  7. .NET Assemblies
  8. Differences between VB.NET 1.0 and VB.NET 2.0
  9. Introducing VB.NET Windows Forms
  10. Visual Studio Windows Forms Designer
  11. Exploring the Forms Designer generated code
  12. Setting and Adding Properties to Windows Form
  13. Implementing Inheritance
  14. Event Handling In Visual Basic .NET
  15. Building Graphical Interface elements
  16. .NET Common Windows Forms Controls Part 1
  17. .NET Common Windows Forms Controls Part 2
  18. Common Controls and Handling Control Events
  19. DomainUpDown and NumericUpDown Controls
  20. Dialog Boxes in Visual Basic .NET
  21. Visual Studio Adding Controls to Windows Form
  22. VB.NET Validation Controls
  23. Working with Menu Controls
  24. VB.NET MDI Applications
  25. .NET Exceptions
  26. VB.NET Creating and Managing Components Part 1
  27. VB.NET Creating and Managing Components Part 2
  28. Simple Data Binding
  29. .NET Complex Data Binding
  30. .NET Data Form Wizard
  31. Data Manipulation with ADO.NET
  32. SQL Server Stored Procedures
  33. SQL Server Ad Hoc Queries
  34. Finding and Sorting Data in DataSets
  35. ADO.NET Object Model
  36. Working with DataSets
  37. Using XML Data
  38. Working with File System in .NET
  39. Creating Web Service
  40. Instantiating - Invoking Web Services, Creating Proxy Classes with WSDL
  41. Web Reference and Web Services
  42. Web Services - SOAP, WSDL, Disco and UDDI
  43. Web Application Testing in VB.NET 2005
  44. Web Application Tracing and Debugging
  45. Working with Legacy Code and COM Components
  46. ActiveX Controls and Legacy Code
  47. Windows Application Testing
  48. VB.NET Windows Application Testing
  49. Tracing VB.NET Windows Application
  50. Debugging Windows Applications In Visual Studio.NET 2005
  51. Deploying Windows Applications In Visual Studio.NET 2005
  52. Customizing Setup Project in Visual Studio.NET 2005
  53. Shared Assembly
  54. Microsoft .NET Creating Installation Components
  55. The Registry Editor in Visual Studio.NET 2005
  56. The File Types Editor

Ads


Home arrow Technical Training arrow VB.NET 2005

Dialog Boxes in Visual Basic .NET

Author : Exforsys Inc.     Published on: 21st Jun 2005    |   Last Updated on: 24th Dec 2007

Dialog Boxes in Visual Basic .NET

Most Windows applications request for user input. Dialog boxes are one means of requesting users for specific kinds of inputs. Therefore, VB.NET allows its designers to create a number of different types of dialog boxes. Standard Dialog boxes are included in classes that fall within the purview of the CommonDialog.

  1. FileDialog
  2. ColorDialog
  3. FontDialog
  4. PageSetupDialot
  5. PrintDialog

Ads

Let us now briefly study the features of the CommonDialog boxes

OpenFileDialogClass

This class provides users with the file selection capability. The properties and methods of this dialog boxes are given below:

Property or Method

Description

ShowDialog

Displays the dialog

MultiSelect

Sets/unsets the selection of multiple files

ShowReadOnly

Sets/unsets the read-only check box checked

Filter

Sets the type of files that will appear in the dialog box

FilterIndex

Sets the index of the filter selected in the dialog box

SaveFileDialog Class

The SaveFileDialog class offers you the standard window that we see while saving the file. The methods and properties of this dialog box are given below:

Property or Method

Description

ShowDialog

Displays the message

CheckFileExists

Checks for the existence of file specified

FileName

Determines the file name selected by the user

Filter

Condition for files to be shown in the dialog box

FilterIndex

Determine the index of the filter selected in the dialog box

The ColorDialog Class

This dialog box shows the color palette for allowing user to select a color and add that color to the palette. The properties of the Class are given below:

Property or Method

Description

ShowDialog

Displays the dialog box

Color

Determines the color selected by the user

AllowFullOpen

Specifies if the user can add custom colors to the box

SolidColorOnly

Determines if the user can use dithered colors

The following screenshot shows the usage of the color palette:

Create a new Visual Basic Windows Applications project in the Visual Studio IDE . To the form Form1 add a ColorDialogBox. Add two Buttons and name them as given below:

Now in the code behind form add the following codes:

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Me.ColorDialog1.ShowDialog()

Label1.ForeColor = Me.ColorDialog1.Color

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Me.Close()

End Sub

End Class

Press F5 to execute the program

Ads

The three screenshots below illustrate how different common dialog boxes are displayed..

“Change Color” button opens the ColorDialog box. You can choose any color from the palette and click Ok. (The codes for event handling of Ok and Cancel button in the ColorDialogBox are not given in this program. You may however write it as shown earlier, if you want to see the impact of your program.) The next screenshot will show the changed fore color of the label1:

Creating a Custom Dialog Box

  • In a new project which already has a form Form1, add another form and name it as FixeDialog.
  • Set the Text property of this form as “Add Text”.
  • Add a label control, a text box control and two command buttons.
  • Change the text property of the label to “Enter Your Text!” and name the first button OK and the other as Cancel.
  • In the property sheet of the form set the FormBorderStyle property to FixedDialog
  • Set the ControlBox property as false. This is done to remove minimize, maximize and close buttons.
  • Enter the following codes for the Dialog Form:

Click here for the Sample Code

Now press F5 to execute the program. The Following sequence of three screenshot will illustrate the working of the form:

The first screenshot shows the initial screen of the program:

The following screenshot shows the custom dialog box opened with the new text typed in the text box:

The final screenshot shows the changed label text as shown below:



 
This tutorial is part of a VB.NET 2005 tutorial series. Read it from the beginning and learn yourself.

VB.NET 2005

  1. VB.NET 2005 Free Training
  2. The .NET Framework Architecture Part 1
  3. The .NET Framework Architecture Part 2
  4. Application Class and Message Class
  5. Implementing Class Library Object
  6. Visual Studio.NET Namespaces
  7. .NET Assemblies
  8. Differences between VB.NET 1.0 and VB.NET 2.0
  9. Introducing VB.NET Windows Forms
  10. Visual Studio Windows Forms Designer
  11. Exploring the Forms Designer generated code
  12. Setting and Adding Properties to Windows Form
  13. Implementing Inheritance
  14. Event Handling In Visual Basic .NET
  15. Building Graphical Interface elements
  16. .NET Common Windows Forms Controls Part 1
  17. .NET Common Windows Forms Controls Part 2
  18. Common Controls and Handling Control Events
  19. DomainUpDown and NumericUpDown Controls
  20. Dialog Boxes in Visual Basic .NET
  21. Visual Studio Adding Controls to Windows Form
  22. VB.NET Validation Controls
  23. Working with Menu Controls
  24. VB.NET MDI Applications
  25. .NET Exceptions
  26. VB.NET Creating and Managing Components Part 1
  27. VB.NET Creating and Managing Components Part 2
  28. Simple Data Binding
  29. .NET Complex Data Binding
  30. .NET Data Form Wizard
  31. Data Manipulation with ADO.NET
  32. SQL Server Stored Procedures
  33. SQL Server Ad Hoc Queries
  34. Finding and Sorting Data in DataSets
  35. ADO.NET Object Model
  36. Working with DataSets
  37. Using XML Data
  38. Working with File System in .NET
  39. Creating Web Service
  40. Instantiating - Invoking Web Services, Creating Proxy Classes with WSDL
  41. Web Reference and Web Services
  42. Web Services - SOAP, WSDL, Disco and UDDI
  43. Web Application Testing in VB.NET 2005
  44. Web Application Tracing and Debugging
  45. Working with Legacy Code and COM Components
  46. ActiveX Controls and Legacy Code
  47. Windows Application Testing
  48. VB.NET Windows Application Testing
  49. Tracing VB.NET Windows Application
  50. Debugging Windows Applications In Visual Studio.NET 2005
  51. Deploying Windows Applications In Visual Studio.NET 2005
  52. Customizing Setup Project in Visual Studio.NET 2005
  53. Shared Assembly
  54. Microsoft .NET Creating Installation Components
  55. The Registry Editor in Visual Studio.NET 2005
  56. The File Types Editor
 

Comments