[RESOLVED] Check Boxes and Radio buttons
I have 8 check boxes and 4 radio buttons on a child form.
When the User checks a Check Box, they then select a radio button. They will do this for 1 to 8 of the check boxes.
The only way I could think of to keep track of this is create 8 panels with 4 unique radio buttons in each. Then I would set the visibility to each one accordingly. This method has other logistical errors than just trying to get the design view worked out.
I was wondering if there was a way to just use the radio buttons. I thought I could set a boolean variable to keep track of each Check Box's Radio buttons. Or an integer variable.
For instance, if Check Box 1 is checked and Radio Button 1 is checked then myVariable's value is 1 or whatever. Then when I actually run the app, I can check the value of the variable do do what I need.
Does this sounds plausible?
Any information you all can provide would be helpful. Thanks
Re: Check Boxes and Radio buttons
I've no idea what you're trying to do, and where you're failing at that. Can you explain a little more carefully, also explaining what the check boxes and radio buttons should do? Maybe an example?
Re: Check Boxes and Radio buttons
Okay. When the User clicks a button, the application will check to see what items are checked and then execute specific functions based on the selections.
The problem I have is that each check box needs to have it's own panel with 4 different radio buttons. When the User checks a Check box, it brings the correct panel into view and then allows the user to select the correct radio buttons.
With 8 panels, this can get very confusing for me and I'd have trouble working with it in design view and code view because of all the Visible checks I would need to do.
So, in code, this is what I've been doing:
vb Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If CheckBox1.Checked = True Then
Panel1.Visible = True
Else
Panel1.Visible = False
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If CheckBox1.Checked = True Then
If RadioButton1.Checked = True Then
End If
If RadioButton2.Checked = True Then
End If
End If
I'll actually be using Case statements, but this illustrates what I need to do best.
Below is a mock up image:
http://img249.imageshack.us/img249/8687/72093863.png
In that image, you'll see just one panel with 4 radio buttons. But I'll need 8 panels with 4 each making it 32 radio buttons.
I don't want to do it this way, because I'll have to stack them on top of each other and keep doing the visible is true and visible = false thing.
So, I was thinking that I could set a variable as an integer and set it's value to 0. then, inside of the Radio Button's CheckedChanged event, I could set the variables integer to whatever value when that button is check and clear it when it is not.
Then, inside of the button's Clicked event, I could analyze the variables and commit action based on their values.
Does that help a bit?
Re: Check Boxes and Radio buttons
I don't like it, and from your question, neither do you. The problem I have with it is that the user lacks feedback. Suppose they check checkbox1, select a radiobutton, check checkbox2....then want to go back and change the radiobutton for checkbox1. What do they do? The radio buttons are now set for checkbox2. Do they have to uncheck checkbox1 then re-check it? That isn't intuitive. People are being asked to undo when they want to review.
From the looks of your form, which may be only a partial form, it appears that you could put 8 panels on there with 8 sets of four radio buttons, and 8 checkboxes. You wouldn't let the user select the checkbox in that case, though. In fact, the checkbox would be disabled. Instead, when they check one of the radio buttons, the checkbox is checked automatically (assuming that if the checkbox is checked then one of the radio buttons MUST be checked). The checkbox is there so that the user can de-select the checkbox, at which point all the radio buttons are deslected.
Another alternative would be to have a tab control with roughly the same set of features.
Re: Check Boxes and Radio buttons
I don't want to use this method. For the reasons you mentioned, Shaggy Hiker, and for all the controls that I would need to use.
I only explained it so I could receive a suggestion on an alternative.
Could I not just use 4 radio buttons and use variables? It seems like it would work, but I don't know how I would allow the user to select a different radio button if they wanted to go back.
I'm going to play around with it a little more and see what I get.
Re: Check Boxes and Radio buttons
Yeah, it's the ability to undo what you have done that will be difficult. Another option would be a wizard-style design where you have a NEXT and BACK button so that the user can cycle through the sets of radio buttons. The variable would certainly work for holding the state of the buttons for any panel.
Re: Check Boxes and Radio buttons
Thanks to the both of you. I ended up using the variables. It's a bit more code than I realized, but it looks like it is going to work just fine.
I'll use a lot fewer controls, which is great, and there won't be that much confusion in the code as long I note it correctly.
I guess all I needed was to "voice" my ideas for the solution to come to me ;)