radio button in vb.net 2005

vb.net United States
  • 13 years ago

    I need help to write the code for selecting and deselecting the radibutton.

    For Ex: i  have radiobutton which inital state will be not selected once after selecting by mistake i want to unselect it.Please let me know if am not clear..

    PS;I dont want to use checkbox for this functionality........

  • 13 years ago

    You must forgive me for saying this, but your question is a little dumb, because how is the client to know if the user is making a mistake clicking the radio button. Equally, people who are not making a mistake will be annoyed/confused by the contrary nature of the button. Anyway, you can achieve the desired effect:

        Private i As Integer = 0
        Private Sub RadioButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButton1.Click
            If i = 0 Then
                RadioButton1.Checked = False
                i += 1
            Else
                i = 0
                Return
            End If
        End Sub
    
  • 13 years ago
    If the user selects the wrong RadioButton then they just have to click another to make the correct selection.  If you want to clear all RadioButtons for some reason then you would, as suggested, set their Checked properties to False.
  • 13 years ago

    Thanks for the reply.Its working.

     

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“A computer lets you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila” - Mitch Ratcliffe