By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,785 Members | 2,074 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,785 IT Pros & Developers. It's quick & easy.

Radio button practical use

P: n/a
I have a field in a database called Language. This field may contain a E
for english or an S for spanish. I would like to use this field in
conjunction with two radio buttons. I know how to drag two radios to my
winform and put them in a groupbox. What is not clear to me is how to
populate (put a radio in) the English or Spanish radio with the value of the
language field when a new record is retrieved. What is the logic here? How
is this done?

Nov 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Thank You.

Yes but Cor, the question was not addressed.

The question is "how to populate the English or Spanish radio with the value
of the
language field when a new record is retrieved". Is there something in the
component that will do it automatically, i.e, if the field value of the
language field is S then put a dot in the Spanish radio or if the field
value is E put a dot in the English radio? If there is not something
built-in what is the method? Could someone give a code example and tell
what method it should go in?

If there is a Microsoft rep I would appreciate your input.
Nov 20 '05 #2

P: n/a
Cor
Woody,
Do you mean
\\\\
If X="S" then
me.radiobutton1.selected = true 'And automatic radiobutton2.selected =
false
else
me.radiobutton2.selected=true
end if
Or
If X="S" then
me.radiobutton1.text ="English"
me.radiobutton1.selected=true
me.radioButton2.text="Spanish"
Else
me.radiobutton1.text="Angli???"
me.radiobutton2.selected=true
me.radiobutton2.text="Espagnol"
end if
////
That is what I can think of very easy and after a while nice readable.

Or do you mean something like this
\\\\\
X is your database item.
Me.rdbEnglish.Checked=Ctype(Instr(X,"E"),Boolean)
me.rdbSpanish.Checked=Ctype(instr(X,"S"),Boolean)
//////
(I hope Herfried does not see this instruction, I always say I hate those
old VB functions like Instr but this one fits exact for this case)

Doing it with a bitwise operator will maybe go too, but makes is again more
unreadable I think.

One of these must do it I think

Cor
Nov 20 '05 #3

P: n/a
Cor
Woody
I did by accident switch in the second example again the S and the E, but
that you did see yourself I asume.
Cor
Nov 20 '05 #4

P: n/a
>Do you mean...

Not really. I mean I would like to know if the VS RadioButton Component has
a way of putting a dot in itself depending on the value of a given field.
When retrieving a record I do not want to have to tell VS to put a dot in
this or that button depending on the value of the Language field, I am
hoping it has the capacity to figure that out for itself. If I have to do
that each time I retrieve or move to a new record it's going to be a lot of
hassle.

Continuing, if I retreive a record to a winform and that record has a field
called language and I have two RadioButtons in a GroupBox labeled English
and Spanish, is VS smart enough to put a dot in the right radio button
depending on what is in the language field or do I have to do it myself?
If you know the answer that would be good. If not, don't feel bad, we all
don't know something, but perhaps you could help me to get an answer from
someone that does.


"Cor" <no*@non.com> wrote in message
news:3f***********************@reader20.wxs.nl...
Woody,
Do you mean
\\\\
If X="S" then
me.radiobutton1.selected = true 'And automatic radiobutton2.selected =
false
else
me.radiobutton2.selected=true
end if
Or
If X="S" then
me.radiobutton1.text ="English"
me.radiobutton1.selected=true
me.radioButton2.text="Spanish"
Else
me.radiobutton1.text="Angli???"
me.radiobutton2.selected=true
me.radiobutton2.text="Espagnol"
end if
////
That is what I can think of very easy and after a while nice readable.

Or do you mean something like this
\\\\\
X is your database item.
Me.rdbEnglish.Checked=Ctype(Instr(X,"E"),Boolean)
me.rdbSpanish.Checked=Ctype(instr(X,"S"),Boolean)
//////
(I hope Herfried does not see this instruction, I always say I hate those
old VB functions like Instr but this one fits exact for this case)

Doing it with a bitwise operator will maybe go too, but makes is again more unreadable I think.

One of these must do it I think

Cor

Nov 20 '05 #5

P: n/a
Cor
Woody,
I think to know what the answers will be, make you own myLanguageRadiobutton
class by inheritting from the radiobuttonclass.
But I don't believe you can do that without using in a way the code I did
supply you.
When you want to bind the data to the button, why not, but you always will
need to translate the S and E to boolean values.
And therefore you need to evaluate the codes in a way of my samples.
What would be more efficient
x = translated code
or
y = translated code
x bind y
I can not see what goal there will be with binding the data in this case.
A radiobutton has only two attributes which can have data.
And you have only 2 radiobuttons.
If you have more you can do such things in a whatever loop but it does not
change the case.
Last message from me in this thread.
Success and when you find your solution I am curious
Cor
Nov 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.