radiobutton question

adshocker

Well-known member
Joined
Jun 30, 2007
Messages
180
Programming Experience
Beginner
is it possible to bind 2 radiobuttons to 1 column in a table... like for example, i have 2 radiobuttons... one labeled male then the other one is female... now in my table i have a gender column... then i want to bind this column to these 2 radiobuttons so if in a record it says male on that column then radiobutton1 will be marked and vice versa....

any suggestions?

thanks...
 
Not sure about this one.

I had a similar issue in one of my apps - a computer audit.

I wanted to have a group box with 3 radio buttons - Desktop, Laptop, Server. In my database these appeared as 1, 2 and 3.

Now, I couldn't work out how to bind rbDesktop to 1, rbLaptop to 2 and rbServer to 3.

Instead, I "hid" a label on my form, bound to the ComputerCategory column.

I then had some code like

VB.NET:
If me.lblCategory.text = 1 Then
me.rbDesktop.Checked = True
ElseIf me.lblCategory.text = 2 Then
me.rbLaptop.Checked = True
ElseIf me.lblCategory.text = 2 Then
me.rbServer.Checked = True
End If

A "dirty" way of doing it, but it was the only way I found worked...
 
You can also just make a custom control that will contain the two radio buttons and will have a property gender that will return a string "Male" or "Female" based on which of them is checked and you can insure that the two are related to one another.

This is because it would be sexist to have a checkbox that says IsMale....
 
is it possible to bind 2 radiobuttons to 1 column in a table... like for example, i have 2 radiobuttons... one labeled male then the other one is female... now in my table i have a gender column... then i want to bind this column to these 2 radiobuttons so if in a record it says male on that column then radiobutton1 will be marked and vice versa....

any suggestions?

thanks...

http://msdn.microsoft.com/msdnmag/issues/04/07/AdvancedBasics/#S1

Or, use a combobox
 
Back
Top