home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic .NET - Read Less - Learn More / Visual_Basic.NET_Read_Less_Learn_More_Richard_Bowman_Visual_2002.iso / Resources / Code / Ch2-DialogBoxes / Form1.vb < prev    next >
Text File  |  2001-06-24  |  3KB  |  103 lines

  1. Public Class Form1
  2.     Inherits System.Windows.Forms.Form
  3.  
  4. #Region " Windows Form Designer generated code "
  5.  
  6.     Public Sub New()
  7.         MyBase.New()
  8.  
  9.         'This call is required by the Windows Form Designer.
  10.         InitializeComponent()
  11.  
  12.         'Add any initialization after the InitializeComponent() call
  13.  
  14.     End Sub
  15.  
  16.     'Form overrides dispose to clean up the component list.
  17.     Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
  18.         If disposing Then
  19.             If Not (components Is Nothing) Then
  20.                 components.Dispose()
  21.             End If
  22.         End If
  23.         MyBase.Dispose(disposing)
  24.     End Sub
  25.     Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
  26.     Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
  27.     Friend WithEvents MenuItem2 As System.Windows.Forms.MenuItem
  28.     Friend WithEvents MenuItem3 As System.Windows.Forms.MenuItem
  29.     Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
  30.  
  31.     'Required by the Windows Form Designer
  32.     Private components As System.ComponentModel.Container
  33.  
  34.     'NOTE: The following procedure is required by the Windows Form Designer
  35.     'It can be modified using the Windows Form Designer.  
  36.     'Do not modify it using the code editor.
  37.     <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
  38.         Me.MenuItem1 = New System.Windows.Forms.MenuItem()
  39.         Me.MenuItem2 = New System.Windows.Forms.MenuItem()
  40.         Me.MenuItem3 = New System.Windows.Forms.MenuItem()
  41.         Me.MainMenu1 = New System.Windows.Forms.MainMenu()
  42.         Me.ListBox1 = New System.Windows.Forms.ListBox()
  43.         Me.SuspendLayout()
  44.         '
  45.         'MenuItem1
  46.         '
  47.         Me.MenuItem1.Index = 0
  48.         Me.MenuItem1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem2, Me.MenuItem3})
  49.         Me.MenuItem1.Text = "&File"
  50.         '
  51.         'MenuItem2
  52.         '
  53.         Me.MenuItem2.Index = 0
  54.         Me.MenuItem2.Text = "&Enter name..."
  55.         '
  56.         'MenuItem3
  57.         '
  58.         Me.MenuItem3.Index = 1
  59.         Me.MenuItem3.Text = "E&xit"
  60.         '
  61.         'MainMenu1
  62.         '
  63.         Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem1})
  64.         '
  65.         'ListBox1
  66.         '
  67.         Me.ListBox1.Location = New System.Drawing.Point(72, 48)
  68.         Me.ListBox1.Name = "ListBox1"
  69.         Me.ListBox1.Size = New System.Drawing.Size(160, 95)
  70.         Me.ListBox1.TabIndex = 0
  71.         '
  72.         'Form1
  73.         '
  74.         Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
  75.         Me.ClientSize = New System.Drawing.Size(292, 273)
  76.         Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.ListBox1})
  77.         Me.Menu = Me.MainMenu1
  78.         Me.Name = "Form1"
  79.         Me.Text = "Form1"
  80.         Me.ResumeLayout(False)
  81.  
  82.     End Sub
  83.  
  84. #End Region
  85.  
  86.     Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem3.Click
  87.         Close()
  88.     End Sub
  89.  
  90.     Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
  91.         Dim Dialog As New Form2()
  92.         Dim Result As DialogResult
  93.  
  94.         ' show the dialog and make this form the parent
  95.         Result = Dialog.ShowDialog(Me)
  96.  
  97.         If Result = DialogResult.OK Then
  98.             ListBox1.Items.Add(Dialog.TextBox1.Text)
  99.         End If
  100.  
  101.     End Sub
  102. End Class
  103.