MessageBox Icon and Button : MessageBox « GUI « VB.Net Tutorial

VB.Net Tutorial
1. Language Basics
2. Data Type
3. Operator
4. Statements
5. Date Time
6. Class Module
7. Development
8. Collections
9. Generics
10. Attributes
11. Event
12. Stream File
13. GUI
14. GUI Applications
15. 2D Graphics
16. I18N Internationlization
17. Reflection
18. Regular Expressions
19. Security
20. Socket Network
21. Thread
22. Windows
23. XML
24. Database ADO.net
25. Design Patterns
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial » GUI » MessageBox 
13. 59. 10. MessageBox Icon and Button
MessageBox Icon and Button
 

Imports System.Windows.Forms

public class RadioButtonAction
   public Shared Sub Main
        Application.Run(New FrmRadioButton)
   End Sub
End class

Public Class FrmRadioButton
   Inherits System.Windows.Forms.Form

   Private iconType As MessageBoxIcon
   Private buttonType As MessageBoxButtons

#Region " Windows Form Designer generated code "

   Public Sub New()
      MyBase.New()

      'This call is required by the Windows Form Designer.
      InitializeComponent()

      'Add any initialization after the InitializeComponent() call

   End Sub

   'Form overrides dispose to clean up the component list.
   Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
      If disposing Then
         If Not (components Is NothingThen
            components.Dispose()
         End If
      End If
      MyBase.Dispose(disposing)
   End Sub
   Friend WithEvents iconGroupBox As System.Windows.Forms.GroupBox
   Friend WithEvents buttonTypeGroupBox As System.Windows.Forms.GroupBox
   Friend WithEvents radRetryCancel As System.Windows.Forms.RadioButton
   Friend WithEvents radYesNo As System.Windows.Forms.RadioButton
   Friend WithEvents radAbortRetryIgnore As System.Windows.Forms.RadioButton
   Friend WithEvents radOk As System.Windows.Forms.RadioButton
   Friend WithEvents radWarning As System.Windows.Forms.RadioButton
   Friend WithEvents radStop As System.Windows.Forms.RadioButton
   Friend WithEvents radQuestion As System.Windows.Forms.RadioButton
   Friend WithEvents radInformation As System.Windows.Forms.RadioButton
   Friend WithEvents radHand As System.Windows.Forms.RadioButton
   Friend WithEvents radExclamation As System.Windows.Forms.RadioButton
   Friend WithEvents radError As System.Windows.Forms.RadioButton
   Friend WithEvents radAsterisk As System.Windows.Forms.RadioButton
   Friend WithEvents cmdDisplay As System.Windows.Forms.Button
   Friend WithEvents lblDisplay As System.Windows.Forms.Label
   Friend WithEvents radOkCancel As System.Windows.Forms.RadioButton
   Friend WithEvents radYesNoCancel As System.Windows.Forms.RadioButton

   'Required by the Windows Form Designer
   Private components As System.ComponentModel.Container

   'NOTE: The following procedure is required by the Windows Form Designer
   'It can be modified using the Windows Form Designer.  
   'Do not modify it using the code editor.
   <System.Diagnostics.DebuggerStepThrough()Private Sub InitializeComponent()
      Me.radAbortRetryIgnore = New System.Windows.Forms.RadioButton()
      Me.radStop = New System.Windows.Forms.RadioButton()
      Me.radYesNo = New System.Windows.Forms.RadioButton()
      Me.iconGroupBox = New System.Windows.Forms.GroupBox()
      Me.radWarning = New System.Windows.Forms.RadioButton()
      Me.radQuestion = New System.Windows.Forms.RadioButton()
      Me.radInformation = New System.Windows.Forms.RadioButton()
      Me.radHand = New System.Windows.Forms.RadioButton()
      Me.radExclamation = New System.Windows.Forms.RadioButton()
      Me.radError = New System.Windows.Forms.RadioButton()
      Me.radAsterisk = New System.Windows.Forms.RadioButton()
      Me.radYesNoCancel = New System.Windows.Forms.RadioButton()
      Me.radOk = New System.Windows.Forms.RadioButton()
      Me.cmdDisplay = New System.Windows.Forms.Button()
      Me.lblDisplay = New System.Windows.Forms.Label()
      Me.buttonTypeGroupBox = New System.Windows.Forms.GroupBox()
      Me.radRetryCancel = New System.Windows.Forms.RadioButton()
      Me.radOkCancel = New System.Windows.Forms.RadioButton()
      Me.iconGroupBox.SuspendLayout()
      Me.buttonTypeGroupBox.SuspendLayout()
      Me.SuspendLayout()
      '
      'radAbortRetryIgnore
      '
      Me.radAbortRetryIgnore.Location = New System.Drawing.Point(1688)
      Me.radAbortRetryIgnore.Name = "radAbortRetryIgnore"
      Me.radAbortRetryIgnore.Size = New System.Drawing.Size(12024)
      Me.radAbortRetryIgnore.TabIndex = 2
      Me.radAbortRetryIgnore.Text = "AbortRetryIgnore"
      '
      'radStop
      '
      Me.radStop.Location = New System.Drawing.Point(16240)
      Me.radStop.Name = "radStop"
      Me.radStop.Size = New System.Drawing.Size(12824)
      Me.radStop.TabIndex = 6
      Me.radStop.Text = "Stop"
      '
      'radYesNo
      '
      Me.radYesNo.Location = New System.Drawing.Point(16160)
      Me.radYesNo.Name = "radYesNo"
      Me.radYesNo.Size = New System.Drawing.Size(12016)
      Me.radYesNo.TabIndex = 4
      Me.radYesNo.Text = "YesNo"
      '
      'iconGroupBox
      '
      Me.iconGroupBox.Controls.AddRange(New System.Windows.Forms.Control() {Me.radWarning, Me.radStop, Me.radQuestion, Me.radInformation, Me.radHand, Me.radExclamation, Me.radError, Me.radAsterisk})
      Me.iconGroupBox.Location = New System.Drawing.Point(20016)
      Me.iconGroupBox.Name = "iconGroupBox"
      Me.iconGroupBox.Size = New System.Drawing.Size(160304)
      Me.iconGroupBox.TabIndex = 3
      Me.iconGroupBox.TabStop = False
      Me.iconGroupBox.Text = "Icon"
      '
      'radWarning
      '
      Me.radWarning.Location = New System.Drawing.Point(16272)
      Me.radWarning.Name = "radWarning"
      Me.radWarning.Size = New System.Drawing.Size(12824)
      Me.radWarning.TabIndex = 7
      Me.radWarning.Text = "Warning"
      '
      'radQuestion
      '
      Me.radQuestion.Location = New System.Drawing.Point(16208)
      Me.radQuestion.Name = "radQuestion"
      Me.radQuestion.Size = New System.Drawing.Size(12824)
      Me.radQuestion.TabIndex = 5
      Me.radQuestion.Text = "Question"
      '
      'radInformation
      '
      Me.radInformation.Location = New System.Drawing.Point(16168)
      Me.radInformation.Name = "radInformation"
      Me.radInformation.Size = New System.Drawing.Size(12824)
      Me.radInformation.TabIndex = 4
      Me.radInformation.Text = "Information"
      '
      'radHand
      '
      Me.radHand.Location = New System.Drawing.Point(16128)
      Me.radHand.Name = "radHand"
      Me.radHand.Size = New System.Drawing.Size(12824)
      Me.radHand.TabIndex = 3
      Me.radHand.Text = "Hand"
      '
      'radExclamation
      '
      Me.radExclamation.Location = New System.Drawing.Point(1688)
      Me.radExclamation.Name = "radExclamation"
      Me.radExclamation.Size = New System.Drawing.Size(13624)
      Me.radExclamation.TabIndex = 2
      Me.radExclamation.Text = "Exclamation"
      '
      'radError
      '
      Me.radError.Location = New System.Drawing.Point(1648)
      Me.radError.Name = "radError"
      Me.radError.Size = New System.Drawing.Size(13624)
      Me.radError.TabIndex = 1
      Me.radError.Text = "Error"
      '
      'radAsterisk
      '
      Me.radAsterisk.Location = New System.Drawing.Point(1616)
      Me.radAsterisk.Name = "radAsterisk"
      Me.radAsterisk.Size = New System.Drawing.Size(13624)
      Me.radAsterisk.TabIndex = 0
      Me.radAsterisk.Text = "Asterisk"
      '
      'radYesNoCancel
      '
      Me.radYesNoCancel.Location = New System.Drawing.Point(16120)
      Me.radYesNoCancel.Name = "radYesNoCancel"
      Me.radYesNoCancel.Size = New System.Drawing.Size(12024)
      Me.radYesNoCancel.TabIndex = 3
      Me.radYesNoCancel.Text = "YesNoCancel"
      '
      'radOk
      '
      Me.radOk.Location = New System.Drawing.Point(1624)
      Me.radOk.Name = "radOk"
      Me.radOk.Size = New System.Drawing.Size(11216)
      Me.radOk.TabIndex = 0
      Me.radOk.Text = "OK"
      '
      'cmdDisplay
      '
      Me.cmdDisplay.Location = New System.Drawing.Point(32240)
      Me.cmdDisplay.Name = "cmdDisplay"
      Me.cmdDisplay.Size = New System.Drawing.Size(11240)
      Me.cmdDisplay.TabIndex = 1
      Me.cmdDisplay.Text = "Display"
      '
      'lblDisplay
      '
      Me.lblDisplay.Location = New System.Drawing.Point(24296)
      Me.lblDisplay.Name = "lblDisplay"
      Me.lblDisplay.Size = New System.Drawing.Size(14424)
      Me.lblDisplay.TabIndex = 5
      '
      'buttonTypeGroupBox
      '
      Me.buttonTypeGroupBox.Controls.AddRange(New System.Windows.Forms.Control() {Me.radRetryCancel, Me.radYesNo, Me.radYesNoCancel, Me.radAbortRetryIgnore, Me.radOkCancel, Me.radOk})
      Me.buttonTypeGroupBox.Location = New System.Drawing.Point(1616)
      Me.buttonTypeGroupBox.Name = "buttonTypeGroupBox"
      Me.buttonTypeGroupBox.Size = New System.Drawing.Size(144216)
      Me.buttonTypeGroupBox.TabIndex = 2
      Me.buttonTypeGroupBox.TabStop = False
      Me.buttonTypeGroupBox.Text = "Button Type"
      '
      'radRetryCancel
      '
      Me.radRetryCancel.Location = New System.Drawing.Point(16192)
      Me.radRetryCancel.Name = "radRetryCancel"
      Me.radRetryCancel.Size = New System.Drawing.Size(10416)
      Me.radRetryCancel.TabIndex = 5
      Me.radRetryCancel.Text = "RetryCancel"
      '
      'radOkCancel
      '
      Me.radOkCancel.Location = New System.Drawing.Point(1656)
      Me.radOkCancel.Name = "radOkCancel"
      Me.radOkCancel.Size = New System.Drawing.Size(12024)
      Me.radOkCancel.TabIndex = 1
      Me.radOkCancel.Text = "OKCancel"
      '
      'FrmRadioButton
      '
      Me.AutoScaleBaseSize = New System.Drawing.Size(513)
      Me.ClientSize = New System.Drawing.Size(384333)
      Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.lblDisplay, Me.iconGroupBox, Me.buttonTypeGroupBox, Me.cmdDisplay})
      Me.Name = "FrmRadioButton"
      Me.Text = "RadioButtonTest"
      Me.iconGroupBox.ResumeLayout(False)
      Me.buttonTypeGroupBox.ResumeLayout(False)
      Me.ResumeLayout(False)

   End Sub

#End Region

   Private Sub cmdDisplay_Click(ByVal sender _
      As System.Object, ByVal e As System.EventArgs_
      Handles cmdDisplay.Click

      Dim dialog As DialogResult = MessageBox.Show_
         "Your message""Title", _
         buttonType, iconType)

      Select Case dialog
         Case DialogResult.OK
            lblDisplay.Text = "OK was pressed"
         Case DialogResult.Cancel
            lblDisplay.Text = "Cancel was pressed"
         Case DialogResult.Abort
            lblDisplay.Text = "Abort was pressed"

         Case DialogResult.Retry
            lblDisplay.Text = "Retry was pressed"

         Case DialogResult.Ignore
            lblDisplay.Text = "Ignore was pressed"

         Case DialogResult.Yes
            lblDisplay.Text = "Yes was pressed"

         Case DialogResult.No
            lblDisplay.Text = "No was pressed"
      End Select

   End Sub ' cmdDisplay_Click

   Private Sub radOk_CheckedChanged(ByVal sender _
      As System.Object, ByVal e As System.EventArgs_
      Handles radOk.CheckedChanged

      buttonType = MessageBoxButtons.OK
   End Sub 
   
   Private Sub radOkCancel_CheckedChanged(ByVal sender _
      As System.Object, ByVal e As System.EventArgs_
      Handles radOkCancel.CheckedChanged

      buttonType = MessageBoxButtons.OKCancel
   End Sub 
   
   Private Sub radAbortRetryIgnore_CheckedChanged(ByVal sender _
      As System.Object, ByVal e As System.EventArgs_
      Handles radAbortRetryIgnore.CheckedChanged

      buttonType = MessageBoxButtons.AbortRetryIgnore
   End Sub 
   
   Private Sub radYesNoCancel_CheckedChanged(ByVal sender _
      As System.Object, ByVal e As System.EventArgs_
      Handles radYesNoCancel.CheckedChanged

      buttonType = MessageBoxButtons.YesNoCancel
   End Sub
   
   Private Sub radYesNo_CheckedChanged(ByVal sender _
      As System.Object, ByVal e As System.EventArgs_
      Handles radYesNo.CheckedChanged

      buttonType = MessageBoxButtons.YesNo
   End Sub
   
   Private Sub radRetryCancel_CheckedChanged(ByVal sender _
      As System.Object, ByVal e As System.EventArgs_
      Handles radRetryCancel.CheckedChanged

      buttonType = MessageBoxButtons.RetryCancel
   End Sub
   
   Private Sub radAsterisk_CheckedChanged(ByVal sender _
      As System.Object, ByVal e As System.EventArgs_
      Handles radAsterisk.CheckedChanged

      iconType = MessageBoxIcon.Asterisk
   End Sub
   
   Private Sub radError_CheckedChanged(ByVal sender _
      As System.Object, ByVal e As System.EventArgs_
      Handles radError.CheckedChanged

      iconType = MessageBoxIcon.Error
   End Sub 
   
   Private Sub radExclamation_CheckedChanged(ByVal sender _
      As System.Object, ByVal e As System.EventArgs_
      Handles radExclamation.CheckedChanged

      iconType = MessageBoxIcon.Exclamation
   End Sub 
   
   Private Sub radHand_CheckedChanged(ByVal sender _
      As System.Object, ByVal e As System.EventArgs_
      Handles radHand.CheckedChanged

      iconType = MessageBoxIcon.Hand
   End Sub 
   
   Private Sub radInformation_CheckedChanged(ByVal sender _
      As System.Object, ByVal e As System.EventArgs_
      Handles radInformation.CheckedChanged

      iconType = MessageBoxIcon.Information
   End Sub 
   
   Private Sub radQuestion_CheckedChanged(ByVal sender _
      As System.Object, ByVal e As System.EventArgs_
      Handles radQuestion.CheckedChanged

      iconType = MessageBoxIcon.Question
   End Sub 
   
   Private Sub radStop_CheckedChanged(ByVal sender _
      As System.Object, ByVal e As System.EventArgs_
      Handles radStop.CheckedChanged

      iconType = MessageBoxIcon.Stop
   End Sub 
   
   Private Sub radWarning_CheckedChanged(ByVal sender _
      As System.Object, ByVal e As System.EventArgs_
      Handles radWarning.CheckedChanged

      iconType = MessageBoxIcon.Warning
   End Sub 

End Class 

        
13. 59. MessageBox
13. 59. 1. MessageBox with Message onlyMessageBox with Message only
13. 59. 2. MessageBox with Message and TitleMessageBox with Message and Title
13. 59. 3. MessageBox with OK, Cancel button and InformationMessageBox with OK, Cancel button and Information
13. 59. 4. MessageBox with Yes No Cancel button and Question iconMessageBox with Yes No Cancel button and Question icon
13. 59. 5. MessageBox OK and Cancel ButtonMessageBox OK and Cancel Button
13. 59. 6. MessageBox: Abort, Retry, Ignore buttons and Warning iconMessageBox: Abort, Retry, Ignore buttons and Warning icon
13. 59. 7. Set default button for MessageBoxSet default button for MessageBox
13. 59. 8. Displaying square root of 2 in dialog.
13. 59. 9. Return value from MessageBox
13. 59. 10. MessageBox Icon and ButtonMessageBox Icon and Button
13. 59. 11. Custom your MessageBoxCustom your MessageBox
13. 59. 12. Create MessageBox dynamicallyCreate MessageBox dynamically
ww_w._j___a_v___a__2s_.__c__om___ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.