Yahoo Answers is shutting down on 4 May 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

RadioBUttonList in VB Express 2012?

I am trying to use a RadioButtonList in my program but cannot find the control in the Toolbox. Is it even in VB Express 2012 for Windows Desktop?

Update:

I'm pretty much trying to get the index of the selected radiobutton in the group. RadioButtonList has 'SelectedIndex' that would give it right away.

1 Answer

Relevance
  • 8 years ago
    Favourite answer

    RadioButtonList is a Web only control. It is in VB Express, but only when you are writing a web app.

    Radio buttons tend to be a lot easier to deal with in a Desktop app than a web app. Typically you just group them together in a group box or a panel and they just work. (See link).

    But maybe you are trying to do something more complex? If so, forget RadioButtonList, you don't have that. Tell us what you want to accomplish on the desktop with radio buttons, and somebody here might be able to answer.

    ETA:

    The simplest way is just to track the currently selected radio button when it is clicked.

    Add a CheckedChanged event handler for each radio button. Double clicking the button in the forms designer will do that for you. Use a class variable to hold the currently selected button. The event handler just needs to do:

    Private Sub RadioButton1_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton1.CheckedChanged

        selectedButton = 1

    End Sub

    Then just check the value of selectedButton when you need it.

    Or you can write a function that does:

    if RadioButton1.Checked then

      return 1

    else if RadioButton2.Checked

      return 2

    etc...

    In a desktop app, it is *UBER* cheap to do some small action when a radio button is checked. In a Web app, it is really expensive, since it can mean a postback that has to repaint the entire web page. So in Desktop, there isn't a RadioButtonList just because you can do the same sort of thing with no real cost.

Still have questions? Get answers by asking now.