title: How to make radiobutton click event add item to dictionary
body: <p>I have a form with several radio buttons that gets created during run-time. The number of radio buttons will change depending on number of records in the db.
  I can get the value from click event but, cannot add another item to dictionary. The code below, shows only information from current click event and does not add another item for second, third, and so on...click events.</p>
  
  <pre><code>Public Sub RadClick(ByVal sender As Object, ByVal e As System.EventArgs)
      Dim rb As RadioButton
      Dim myDictionary As New Dictionary(Of Integer, String)
      Dim x As Integer = 0
  
      rb = DirectCast(sender, RadioButton)
      If rb.Checked = True Then
          x = x + 1
          myDictionary.Add(x, rb.Name)
      End If
  
      For Each pair As KeyValuePair(Of Integer, String) In myDictionary
          MsgBox(pair.Key &amp; " - " &amp; pair.Value)
      Next
  
  End Sub
  </code></pre>