I am writing a game and when opening a form certain radio buttons are set automatically in different tabs. They are options that change variables in game play, like weapon choices. When closing the form and reopening the the form the radio buttons go back to preset, I want them to stay where the user put them, but I can't leave the form open. Also, If I close the form and reopen it without declaring it there is disposing error.
Private Sub optionsbutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles optionsbutton.Click
Dim usefrmoptions As New Form()
usefrmoptions.Show()
End Sub
This works but makes new each time with preset, and if i declare usefrmoptions at the beggining of the frmmain then disposing error occurs after opening, closing, then triing to open the frmoptions again.
Comments
: Private Sub optionsbutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles optionsbutton.Click
: Dim usefrmoptions As New Form()
: usefrmoptions.Show()
:
: End Sub
: This works but makes new each time with preset, and if i declare usefrmoptions at the beggining of the frmmain then disposing error occurs after opening, closing, then triing to open the frmoptions again.
:
I use a global variable (integer) to hold the value of the RadioButton selected from each group. Only way I know how to do this is using a Module. I'm sure theres a fancy OOP way to do this, but I haven't found it, and this works now. I preset the value in the main form OnLoad sub (not OnActivate). When the dialog form opens its OnActivated code uses a Select statement to set the proper Radiobuttons checked property. The first time through it should have the value preset in the main form. In the OnClick methods for the radiobuttons set the global variable to the index of the radio button. (Remember zero-based). Subsequent calls work properly.