组框和单选按钮. [英] Group Box and Radio Button.

查看:73
本文介绍了组框和单选按钮.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个分组框,其中放置了两个单选按钮,即男性"和女性".我想通过一行数据集来传递在sql server数据库的组框中选择的任何一个单选按钮.如果我选择男性"单选按钮,则在数据库中它应显示为男性",如果我选择女性",则它应在数据库中显示为女性".
编码应该如何:
dr [0] = groupbox.any属性或
dr [0] = radiobutton.any属性
请帮帮我!
在此先谢谢您!!!!

I have an group box in which I have placed two radio buttons i.e Male and Female. I want to pass the any one radio button selected in the group box in the sql server database through dataset in one row. If I select Male radio button then in the database it should appear as Male, If I select Female then it should appear as Female in database.
how should be the coding:
dr[0] = groupbox.any property or
dr[0] = radiobutton.any property
Please help me!
Thanks In Advance!!!

推荐答案

您好家伙在单选按钮中使用组名属性为两者设置了相同的组名.将表字段设置为gender_status,对于女性考虑F,对于男性考虑M.在表中存储F或M.

我的意思是

if(radiobutton1.Checked)
{val ="F";}
if(radiobutton2.Checked)
{val ="M";}
hi dude use group name property in radio button set same group name for both. set the table field as gender_status consider F for female and M for Male.store F or M in the table.

i mean

if(radiobutton1.Checked)
{val="F";}
if(radiobutton2.Checked)
{val="M";}


好吧,您尝试了什么?首先如何将性别存储为字符串?如果(male.IsChecked)dr [0] =女人",否则dr [0] =男人"呢? ???
Well, what have you tried ? How are you storing the gender in the first place, as a string ? How about if (male.IsChecked) dr[0] = "Woman" else dr[0] = "Man"; ???


不,最好使用三元运算符.我可能会使用它,但是缩短代码并不能使它变得更好,也不会更快,并且对于那些没有经验的人来说,它更难阅读,这就是为什么我按照我的方式列出答案的原因.
No, it''s not better to use the ternary operator. I probably WOULD use it, but making the code shorter does not make it better, it''s no faster, and for someone inexperienced, it''s harder to read, which is why I laid out my answer the way I did.


这篇关于组框和单选按钮.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆