RadioButtonlist

niall29

Freshman
Joined
Sep 13, 2004
Messages
35
This is probably a silly question but I want to say if nothing is selected in the Radiobuttonlist. it will display a message box saying you need to pick one"

I can get the message box but I dont know how to say if nothing is selected.
 
If I'm not mistaken, I'm pretty sure that at least one radio button has to be selected at all times. Generally, if you click one, it becomes selected while the one that was previously selected becomes unselected. On the other hand, you can have no selections in a list of CheckBoxes. So if you are using a RadioButtonList you should always have one selected. Else, just have your program go through each CheckBox and evaluate its Checked property to see if any of them are checked.
 
You are right with radio buttons you have to pick one. but when the form opens none of them have been picked yet.
You see I have the Radiobuttonlist set to a table and what I plan to do is link that table to another table of field names so when they pick Search by first name it will know to search the field F_name and if the user picks Last Name then it knows to search L_name but I do not want to use If and Else IF statements because what I am trying to do is Allow the user to put in new search categorys without having to change the code.

i hope this helps to understand what Im trying to do and maybe its not possible but I will never find out unless I try.
 
Have a class variable:
Private nOption As Int16
When the form loads, initialize nOption to -1
If user clicks on RadioButton1 (use click event) then nOption = 1
if user clicks on RadioButton2 then nOption = 2
etc....
Basically, nOption keeps track of which RadioButton is currently selected.
when the user clicks Search (or whatever) then if nOption is still equal to -1,
you know that the user never clicked a RadioButton.
 
Back
Top