Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
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

Its C# code, I've solved yesterday similar kinda question :
C#
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/[^]
 
Share this answer
 
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 :)
 
Share this answer
 
Comments
AnkitGoel.com 10-Dec-12 0:03am    
should be posted as comments.
hi,
like this:

VB
Private Sub ResetTxtBox()
    For Each x As TextBox In Me.Controls
        x.Text = String.Empty
    Next
End Sub
 
Share this answer
 
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900