Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class AddressForm
- ' Clear Form's TextBoxes, ComboBoxes, and MaskedTextBoxes
- Private Sub ClearButton_Click(sender As Object, e As EventArgs) _
- Handles ClearButton.Click
- ClearAll(Me)
- BillToSameCheckBox.Checked = False
- FirstNameTextBox.Select()
- End Sub
- ' Clear TextBoxes, ComboBoxes, and MaskedTextBoxes
- Private Sub ClearAll(ByVal ctrlContainer As Control)
- For Each ctrl As Control In ctrlContainer.Controls
- If TypeOf ctrl Is TextBox OrElse
- TypeOf ctrl Is ComboBox OrElse
- TypeOf ctrl Is MaskedTextBox Then
- ctrl.Text = String.Empty
- If TypeOf ctrl Is ComboBox Then
- Dim aComboBox = DirectCast(ctrl, ComboBox)
- aComboBox.SelectedIndex = -1
- End If
- End If
- ' If the control has children,
- ' recursively call this function
- If ctrl.HasChildren Then
- ClearAll(ctrl)
- End If
- Next
- End Sub
- ' Quick fill Bill To data
- Private Sub BillToSameCheckBoxx_CheckedChanged(sender As Object, e As EventArgs) _
- Handles BillToSameCheckBox.CheckedChanged
- If BillToSameCheckBox.Checked Then
- BillToFirstNameNextBox.Text = FirstNameTextBox.Text
- BillToLastNameTextBox.Text = LastNameTextBox.Text
- BillToAddressTextBox.Text = AddressTextBox.Text
- BillToCityTextBox.Text = CityTextBox.Text
- BillToStateComboBox.Text = StateComboBox.Text
- BillToZipCodeMaskedTextBox.Text = ZipCodeMaskedTextBox.Text
- Else
- ClearAll(BillToGroupBox)
- BillToFirstNameNextBox.Select()
- End If
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment