Results 1 to 3 of 3

Thread: User control For Clear All the Control data

  1. #1

    Thread Starter
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Thumbs up 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:
    1. Imports System.Windows.Forms.UserControl
    2. Public Class ResetControl
    3. #Region "Public Event"
    4.     Public Event ClearButtonClicked(ByVal sender As System.Object, ByVal e As System.EventArgs)
    5. #End Region
    6.  
    7. #Region "Private Event"
    8.     Private Sub ClearControl_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ClearControl.Click
    9.         Dim Ctl As Object
    10.         For Each Ctl In Me.Parent.Controls
    11.  
    12.             If TypeOf Ctl Is System.Windows.Forms.TextBox Then Ctl.Text = ""
    13.             If TypeOf Ctl Is System.Windows.Forms.ComboBox Then Ctl.Selectedindex = -1
    14.             If TypeOf Ctl Is System.Windows.Forms.DateTimePicker Then Ctl.value = Date.Now
    15.             If TypeOf Ctl Is System.Windows.Forms.CheckBox Then Ctl.checked = False
    16.             If TypeOf Ctl Is System.Windows.Forms.RadioButton Then Ctl.checked = False
    17.             If TypeOf Ctl Is System.Windows.Forms.ListBox Then Ctl.SelectedIndex = -1
    18.             If TypeOf Ctl Is System.Windows.Forms.RichTextBox Then Ctl.Text = ""
    19.             If TypeOf Ctl Is System.Windows.Forms.UserControl Then
    20.                 ClearText(Ctl)
    21.                 'Clear The Control That are in the user control
    22.             End If
    23.         Next
    24.     End Sub
    25.     Private Sub ClearText(ByVal ControlContainer As Object)
    26.         For Each Ctl As Object In ControlContainer.Controls
    27.             Try
    28.                 If Not Ctl.Controls Is Nothing Then
    29.                     ClearText(Ctl)
    30.                     If TypeOf Ctl Is Windows.Forms.TextBox Then
    31.                         Ctl.text = ""
    32.                     End If
    33.                 End If
    34.             Catch ex As Exception
    35.                 MsgBox(ex.Message)
    36.             End Try
    37.         Next
    38.     End Sub
    39. #End Region
    40. 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.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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.

  3. #3

    Thread Starter
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Thumbs up 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
  •  



Click Here to Expand Forum to Full Width