VB.Net - SPLessons

VB.Net Dialogue Boxes

Home > Lesson > Chapter 31
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

VB.Net Dialogue Boxes

VB.Net Dialogue Boxes

shape Description

While developing any project developer concentrates to reduce the code, then the developer may need easy solutions by using components such as dialogue boxes, combo boxes, etc... This chapter describes how to create dialogue boxes and what is dialogue box. There are more predefined dialogue boxes are used in windows for different tasks such as opening and saving files, printing a page, etc... to an application. All these dialogue boxes are utilized to reduce the burden of the developer.Following is the conceptual figure which describes the types of dialogue boxes.

shape Conceptual Figure

shape Example

Following is an example to open a file from the system. [vbnet]Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim dlg As New OpenFileDialog dlg.ShowDialog() If dlg.ShowDialog = Windows.Forms.DialogResult.OK Then Dim fileName As String fileName = dlg.FileName MsgBox(fileName) End If End Sub End Class[/vbnet] Dialogue box control classes will inherit the properties from the CommonDialog class and it will override the RunDialog () function of the base class to a particular dialogue box. The RunDialog () function will be invoked when the dialog box calls its ShowDialog () function. ShowDialog () is utilized to expose the dialog box controls at dynamically. Output When compile the code following form will be displayed. When click on the button files will be opened from the system.

Summary

shape Points

  • Dialogue boxes will used to reduce the code burden.
  • ShowDialog () is used to open the dialog box controls at run time.