hi there
I am having a small query regarding the vb.net As i am not a programmer in visual basic.net, i jsut want to know as how can i customize dialog box in this programming language.
Please provide your opinion regarding this
hi there
I am having a small query regarding the vb.net As i am not a programmer in visual basic.net, i jsut want to know as how can i customize dialog box in this programming language.
Please provide your opinion regarding this
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.
- FileDialog
- ColorDialog
- FontDialog
- PageSetupDialot
- PrintDialog
Code:Public Class CustomDialog Private Sub CustomDialog_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.AcceptButton = Button1 Me.CancelButton = Button2 Me.TextBox1.Text = "" End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.DialogResult = Windows.Forms.DialogResult.OK Me.Close() 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
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.
Code:Public Class Form1 Dim DialogBox As New CustomDialog() Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If DialogBox.ShowDialog = Windows.Forms.DialogResult.OK Then Me.Label1.Text = DialogBox.TextBox1.Text End If 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
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
Now in the code behind form add the following codes:
Code: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
Bookmarks