Hi all![]()
This is the user control for clearing all the control of the form
Steps Involved
1) File New project select windows controls library
2) Write name of the user control in Reset control
3) Add command button on the form
4) Name of the command button is ClearControl
5) Select docked property =Fill
6) Select Modifiers=Public
7) Write text =Clear
8) Imports the System.Windows.Forms.UserControl
9) Declare the public event
10) Paste the Following code
VB Code:
Imports System.Windows.Forms.UserControl Public Class ResetControl #Region "Public Event" Public Event ClearButtonClicked(ByVal sender As System.Object, ByVal e As System.EventArgs) #End Region #Region "Private Event" Private Sub ClearControl_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ClearControl.Click Dim Ctl As Object For Each Ctl In Me.Parent.Controls If TypeOf Ctl Is System.Windows.Forms.TextBox Then Ctl.Text = "" If TypeOf Ctl Is System.Windows.Forms.ComboBox Then Ctl.Selectedindex = -1 If TypeOf Ctl Is System.Windows.Forms.DateTimePicker Then Ctl.value = Date.Now If TypeOf Ctl Is System.Windows.Forms.CheckBox Then Ctl.checked = False If TypeOf Ctl Is System.Windows.Forms.RadioButton Then Ctl.checked = False If TypeOf Ctl Is System.Windows.Forms.ListBox Then Ctl.SelectedIndex = -1 If TypeOf Ctl Is System.Windows.Forms.RichTextBox Then Ctl.Text = "" If TypeOf Ctl Is System.Windows.Forms.UserControl Then ClearText(Ctl) 'Clear The Control That are in the user control End If Next End Sub Private Sub ClearText(ByVal ControlContainer As Object) For Each Ctl As Object In ControlContainer.Controls Try If Not Ctl.Controls Is Nothing Then ClearText(Ctl) If TypeOf Ctl Is Windows.Forms.TextBox Then Ctl.text = "" End If End If Catch ex As Exception MsgBox(ex.Message) End Try Next End Sub #End Region End Class
Now Bulid the project, after it you are able to get the dll that wiil clear all the data on your form.
Bulid the solution then you are able to get the dll![]()




Reply With Quote