Click here to Skip to main content
Rate this: bad
good
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 Smile | :)
  Permalink  
Comments
AnkitGoel.com at 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 at 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
0 OriginalGriff 328
1 Sergey Alexandrovich Kryukov 295
2 Gihan Liyanage 292
3 ClimerChinna 222
4 Abhinav S 187
0 Sergey Alexandrovich Kryukov 8,213
1 OriginalGriff 7,089
2 CPallini 2,598
3 Richard MacCutchan 1,925
4 Abhinav S 1,778


Advertise | Privacy | Mobile
Web04 | 2.8.140826.1 | Last Updated 9 Dec 2012
Copyright © CodeProject, 1999-2014
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