Click here to Skip to main content
12,510,988 members (56,901 online)
Rate this:
 
Please Sign up or sign in to vote.
I can clear all the text boxes when i press reset button ,ie, txtName.text = "".. i can clear the combo boxes in the same way,but how do i reset the radiobuttons,checkboxes and listbox contents that have been selected.
Posted 8-Dec-12 14:15pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Its C# code, I've solved yesterday similar kinda question :
private void button1_Click_1(object sender, EventArgs e)
       {
           List<TextBox> t = new List<TextBox>();
 
           t.Add(textBox1);
           t.Add(textBox2);
           t.Add(textBox3);
           t.Add(textBox4);
 
           foreach (TextBox txt in t)
           {
               txt.Clear();
           }
 
           comboBox1.SelectedIndex = 0;
           checkBox1.Checked = false;
           radioButton1.Checked = false;
       }
   }
for C# to VB, follow this link : http://converter.telerik.com/[^]
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Thanks for that dude ,but i barely have a grasp of VB.net,being a complete novice and all that.
I need an answer with Vb code,the converter doesn't work,it keeps telling me there is an error.
Much thanks anyway :)
  Permalink  
Comments
AnkitGoel.com 10-Dec-12 0:03am
   
should be posted as comments.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

hi,
like this:

Private Sub ResetTxtBox()
    For Each x As TextBox In Me.Controls
        x.Text = String.Empty
    Next
End Sub
  Permalink  
Comments
AnkitGoel.com 10-Dec-12 0:05am
   
works only for textboxes and throws error in case these are controls other than textbox.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160929.1 | Last Updated 9 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100