Friday, November 7, 2008

Create Custom Message Box VB.NET

Dim frmMsgBx As New Form
Dim lblMsgText As New System.Windows.Forms.Label
Dim btnMsgOpen, btnMsgSave, btnMsgCancel As New System.Windows.Forms.Button

With frmMsgBx
.StartPosition = FormStartPosition.CenterScreen
.MinimizeBox = False
.MaximizeBox = False
.Width = 380
.Height = 150
.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
.ShowIcon = False
.ShowInTaskbar = False
.Text = "Exporting to Excel"
End With

With lblMsgText
.Parent = frmMsgBx
.Left = 30
.Top = 30
.Width = 300
.Height = 13
.Text = "Would you like to open the file or save it to your computer?"
.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
End With

With btnMsgOpen
.Parent = frmMsgBx
.Left = 50
.Top = 80
.Width = 52
.Height = 23
.Text = "Open"
.DialogResult = System.Windows.Forms.DialogResult.OK
End With

With btnMsgSave
.Parent = frmMsgBx
.Left = 110
.Top = 80
.Width = 73
.Height = 23
.Text = "Save"
.DialogResult = System.Windows.Forms.DialogResult.Yes
End With

With btnMsgCancel
.Parent = frmMsgBx
.Left = 250
.Top = 80
.Width = 75
.Height = 23
.Text = "Cancel"
.DialogResult = System.Windows.Forms.DialogResult.Cancel
End With

frmMsgBx.ShowDialog()

No comments: