Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27513

Transfer radio button state to another form

$
0
0
On a form, frmB, I have ten pairs of radio buttons, rbtB1 rbtB2...rbtB20, and each pair is in a panel, pnlB1 pnlB2...pnlB10 and the whole lot is in a group panel, grpB1. On another form, frmA, I have a pair of radio buttons, rbtA1 and rbtA2, also in a panel. When a button is clicked on frmA, the state of the radio buttons (with other information) is to be transferred to a pair on frmB. FrmA is then ready for the next data. I am able to transfer the state for the first instance using the code below. However I can't see how to increment the panel name. Is it possible or am I on the wrong track?
Code:

x = lblCount.Text

If rbtA1.Checked = True Then
            DirectCast(frmB.pnlB1.Controls("rbtB1" & x.ToString), RadioButton).Checked = True
            DirectCast(frmB.pnlB1.Controls("rbtB2" & x.ToString), RadioButton).Checked = False
        Else
            DirectCast(frmB. pnlB1.Controls("rbtB1" & x.ToString), RadioButton).Checked = False
            DirectCast(frmB. pnlB1.Controls("rbtB2" & x.ToString), RadioButton).Checked = True
        End If

Also, I thought that if a pair of radio buttons are in a panel they operate so that one is always on. I have rbtB1 set to CHECKED at design time. If I turn rbtB1 off I end up with both rbtB1 and rbtB2 in the panel in the OFF state. That is the reason that I have two lines in each part of the IF statement. Is this how they are supposed to work?
Thanks

Viewing all articles
Browse latest Browse all 27513

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>