⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 formregistration.vb

📁 Programming the .NET Compact Framework with vb 源代码
💻 VB
📖 第 1 页 / 共 2 页
字号:
      Me.lblStreet.Location = New System.Drawing.Point(8, 6)
      Me.lblStreet.Size = New System.Drawing.Size(56, 16)
      Me.lblStreet.Text = "Street"
      Me.lblStreet.TextAlign = System.Drawing.ContentAlignment.TopRight
      '
      'bttnAdd
      '
      Me.bttnAdd.Location = New System.Drawing.Point(192, 240)
      Me.bttnAdd.Size = New System.Drawing.Size(40, 20)
      Me.bttnAdd.Text = "Add"
      '
      'panelSponsor
      '
      Me.panelSponsor.Controls.Add(Me.lblSponsID)
      Me.panelSponsor.Controls.Add(Me.textSponsID)
      Me.panelSponsor.Location = New System.Drawing.Point(0, 88)
      Me.panelSponsor.Size = New System.Drawing.Size(232, 24)
      '
      'lblSponsID
      '
      Me.lblSponsID.Location = New System.Drawing.Point(8, 1)
      Me.lblSponsID.Size = New System.Drawing.Size(56, 20)
      Me.lblSponsID.Text = "Spons ID"
      Me.lblSponsID.TextAlign = System.Drawing.ContentAlignment.TopRight
      '
      'textSponsID
      '
      Me.textSponsID.Location = New System.Drawing.Point(72, 0)
      Me.textSponsID.Text = ""
      '
      'panelWho
      '
      Me.panelWho.Controls.Add(Me.textName)
      Me.panelWho.Controls.Add(Me.lblName)
      Me.panelWho.Controls.Add(Me.lblID)
      Me.panelWho.Controls.Add(Me.textID)
      Me.panelWho.Location = New System.Drawing.Point(0, 40)
      Me.panelWho.Size = New System.Drawing.Size(232, 48)
      '
      'textName
      '
      Me.textName.Location = New System.Drawing.Point(72, 24)
      Me.textName.Text = ""
      '
      'lblName
      '
      Me.lblName.Location = New System.Drawing.Point(8, 25)
      Me.lblName.Size = New System.Drawing.Size(56, 20)
      Me.lblName.Text = "Name"
      Me.lblName.TextAlign = System.Drawing.ContentAlignment.TopRight
      '
      'panelChild
      '
      Me.panelChild.Controls.Add(Me.lblGender)
      Me.panelChild.Controls.Add(Me.optFemale)
      Me.panelChild.Controls.Add(Me.optMale)
      Me.panelChild.Controls.Add(Me.lblBorn)
      Me.panelChild.Controls.Add(Me.textBorn)
      Me.panelChild.Location = New System.Drawing.Point(0, 184)
      Me.panelChild.Size = New System.Drawing.Size(232, 48)
      '
      'formRegistration
      '
      Me.Controls.Add(Me.panelChild)
      Me.Controls.Add(Me.panelWho)
      Me.Controls.Add(Me.panelSponsor)
      Me.Controls.Add(Me.panelAddress)
      Me.Controls.Add(Me.panelMemberType)
      Me.Controls.Add(Me.bttnAdd)
      Me.Menu = Me.menuMain
      Me.Text = "Register Members"

   End Sub

#End Region

   Private Sub Form_Load(ByVal sender As System.Object, _
                          ByVal e As System.EventArgs _
                          ) _
                          Handles MyBase.Load

      '  Clear the input fields
      ClearTextBoxes(Me)

      '  Place the option buttons in a line along the
      '     top of the form, right justified.
      PositionOptionButtons()

      '  Co-locate the City combobox and 
      '     its associated text box.
      textCity.Bounds = cboxCity.Bounds
      '  Add the "(New Entry)" item at to top of the list.
      '  Select it.
      '  Show the ComboBox
      With cboxCity
         .Items.Insert(0, "(New Entry)")
         .SelectedIndex = 0
         .BringToFront()
      End With
   End Sub

   Private Sub optAny_CheckedChanged( _
                  ByVal sender As System.Object, _
                  ByVal e As System.EventArgs _
                  ) _
                  Handles optAdult.CheckedChanged, _
                          optChild.CheckedChanged, _
                          optAssociate.CheckedChanged

      '  Hide what you do not need, 
      '     show what you do need.
      panelSponsor.Visible = _
         optAssociate.Checked Or optChild.Checked
      panelAddress.Visible = _
         optAdult.Checked Or optAssociate.Checked
      panelChild.Visible = optChild.Checked

      '  Position panels.
      Dim topNext As Integer = panelWho.Bottom
      With panelSponsor
         If .Visible Then
            .Top = topNext
            topNext = .Bottom
         End If
      End With
      With panelAddress
         If .Visible Then
            .Top = topNext
            topNext = .Bottom
         End If
      End With
      With panelChild
         If .Visible Then
            .Top = topNext
            topNext = .Bottom
         End If
      End With
   End Sub

   Private Sub cboxCity_SelectedIndexChanged( _
                     ByVal sender As System.Object, _
                     ByVal e As System.EventArgs _
                     ) _
                     Handles cboxCity.SelectedIndexChanged

      '  If the user requested free form test entry
      If cboxCity.SelectedIndex = 0 Then
         '  Clear the TextBox
         '  Show it
         '  Give it the focus.
         With textCity
            .Text = String.Empty
            .BringToFront()
            .Focus()
         End With
      End If
   End Sub

   Private Sub textCity_Validated( _
                     ByVal sender As System.Object, _
                     ByVal e As System.EventArgs _
                     ) _
                     Handles textCity.Validated

      With cboxCity
         '  The user has completed their data entry
         '     and that data has passed all edits.
         If textCity.Text.Trim <> String.Empty Then
            '  Add their entry to the ComboBox's dropdown list.
            '  Select it.
            '  Show the ComboBox.
            .Items.Insert(1, textCity.Text)
            .SelectedIndex = 1
         End If
         .BringToFront()
      End With
   End Sub

   Private Sub bttnAdd_Click(ByVal sender As System.Object, _
                             ByVal e As System.EventArgs _
                             ) _
                             Handles bttnAdd.Click

      '  Code to register a member goes here 
      '        :
      '        :
      genderMember = IIf(optFemale.Checked, "F", _
                        IIf(optMale.Checked, "M", " "))
      '        :
      '        :
      ClearTextBoxes(Me)
   End Sub

   Private Sub PositionOptionButtons()
      '  Place the option buttons in a line along the
      '     top of the form, right justified.
      With panelMemberType
         .BackColor = Color.Bisque
         .Height = optAdult.Height
         .Width = optAdult.Width _
                + optAssociate.Width _
                + optChild.Width
         .Location = _
            New Point(Me.ClientRectangle.Width - .Width, 0)
      End With
      With optAssociate
         .Location = _
            New Point( _
               panelMemberType.ClientRectangle.Width - .Width _
                     , 0)
      End With
      With optChild
         .Location = _
            New Point(optAssociate.Left - .Width, 0)
      End With
      With optAdult
         .Location = _
            New Point(optChild.Left - .Width, 0)
      End With
   End Sub

   Private Sub ClearTextBoxes(ByVal ctrlContainer As Control)

      Dim theControl As Control
      For Each theControl In ctrlContainer.Controls
         '  Recursively perform this routine.
         ClearTextBoxes(theControl)
         '  Clear all TextBoxes that are first
         '     level children of this control.
         If theControl.GetType.ToString() = _
                     "System.Windows.Forms.TextBox" Then
            theControl.Text = String.Empty
         End If
      Next
   End Sub

End Class


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -