Click here to Skip to main content
15,893,622 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, i am doing a project and i need some help.
i created a button, "clean"
in this button i put this validation, bellow..

Private Sub cleanbt_Click(sender As System.Object, e As System.EventArgs) Handles cleanbt.Click

> If rbbut_company.Checked Then
>> rbbut_company.Checked = False
> ElseIf rdbut_compind.Checked Then
>> rdbut_compind.Checked = False
> ElseIf rbbut_indi.Checked Then
>> rbbut_indi.Checked = False
> End If

My problem is, when I select a radio button, "company" or "any other",by clicking the button "clear" he cleans all, and lives any checked radio button..

Here is an example to understand my problem:

When I start the program the first thing is chosen is the name :
name.radiobutton *
nickname.radiobutton
telefon.radiobutton
email.radiobutton

I choose another term to be different:
name.radiobutton
nickname.radiobutton
telefon.radiobutton *
email.radiobutton

when I click clean, he should go back and select like the first time, when i started the program , the name.
like this:
name.radiobutton *
nickname.radiobutton
telefon.radiobutton
email.radiobutton


but the problem is: he cleans everything,
but i a don't want that. =/


like this:
nome.radiobutton
apelido.radiobutton
telefone.radiobutton
email.radiobutton

nothing selected

i want to go back and select, like the first time, when i started the program , the "name".
what should I do? insert a "For"?

Could you help me please.
I would be very grateful. =)
Posted

Because these are radio buttons only one rb may be checked at any time. Clicking on one of them will automatically clear the rest. The same will happen if you do it in code.

In your code you are setting values to False so the automatic behaviour does not kick in. Try just using
VB
Private Sub cleanbt_Click(sender As System.Object, e As System.EventArgs) Handles cleanbt.Click
     rbbut_company.Checked = True
End Sub
 
Share this answer
 
Comments
Maciej Los 13-May-13 6:46am    
+5
CHill60 13-May-13 6:48am    
Thank you! Same as Solution 1 but I thought I'd attempt to explain why as well :-)
Maciej Los 13-May-13 6:49am    
Yes ;)
VB
name.radiobutton.Checked = True
 
Share this answer
 

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