|
-
Sep 28th, 2006, 05:35 AM
#1
Thread Starter
Just Married
User control For Clear All the Control data
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
Last edited by shakti5385; Sep 28th, 2006 at 07:49 AM.
-
Sep 28th, 2006, 06:45 AM
#2
Re: User control For Clear All the Control data
Attachment removed as it contained just a single compiled .Dll
Compiled code is not permitted in CodeBank attachments.
Please review the CodeBank policy on attachments at the top of this section.
Member sent PM.
-
Sep 28th, 2006, 07:50 AM
#3
Thread Starter
Just Married
Re: User control For Clear All the Control data
I removed the dll attetchment by me...
Bulid the solution then you are able to get the dll and use your project
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|