הערה
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות להיכנס או לשנות מדריכי כתובות.
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות לשנות מדריכי כתובות.
Question
Saturday, May 11, 2013 5:52 AM
How to create a custom messagebox with checkbox option ? and also to use this code in various forms ?
All replies (3)
Saturday, May 11, 2013 6:14 AM ✅Answered
The best solution would be to create a form, add controls that you desire. You would set DialogResult property of each button than use ShowDialog method of the form to determine what button was pressed. For the CheckBox simply access the value.
Example where frmMyDialogForm is a normal Windows Form that you place controls on and for the buttons set DialogResult.
Dim f As New frmMyDialogFormTry If f.ShowDialog = Windows.Forms.DialogResult.OK Then If f.CheckBox1.Checked Then ' ' Do something ' End If End IfFinally f.Dispose()End Try
Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.
Saturday, May 11, 2013 6:15 AM ✅Answered
Maybe like this?
Form1 Code
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Text = "I am Form1"
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim f2 As New Form2
f2.Show()
End Sub
End Class
Form2 Code
Public Class Form2
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Text = "Message Box"
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.Close()
End Sub
Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
MessageBox.Show("O.K.")
End Sub
End Class
You've taught me everything I know but not everything you know.
Saturday, May 11, 2013 6:52 AM ✅Answered
You could do this too.
Public Class Form2
Dim Test As New Drawing.Font("Arial", 30)
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Text = "Message Box"
End Sub
Private Sub Form2_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
Dim string_format As New StringFormat
string_format.Alignment = StringAlignment.Center
string_format.LineAlignment = StringAlignment.Center
e.Graphics.DrawString("Hello this is a test!", Test, Brushes.Red, 200, 50, string_format)
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.Close()
End Sub
Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
MessageBox.Show("O.K.")
End Sub
End Class
You've taught me everything I know but not everything you know.