1. 首页 > 数码 >

radiobutton控件 radiobutton控件单选

c# 在groupbox控件中判断的内嵌的radiobutton是否已选

只有四个radiobutton可以用if(rbtn1.checked==false&&rbtn2.checked==false……)进行判断

radiobutton控件 radiobutton控件单选radiobutton控件 radiobutton控件单选


如果radiobutton个数多的话:

private void button1_Click(object sender, EventArgs e)

{int i = 0;

foreach (RadioButton in groupBox1.Controls)

{if (.Checked)

}if (i == 0)

MessageBox.Show("没有选中任意个radiobutton");

}在Form 代码的任意位置增加初始化控件的过程InitializeControl() 代码如下所示好久没做wrm了……

radioButton有个IsChecked的属性,你可以对radiobutton做判断就行,类似

if (radiobu{if (C is RadioButton&&((RadioButton)C).Checked )tton.ischecked == true)

break;

else if(radiobutton2.ischecked == true)

break;

你在之前定义一个flag来记录就行,如果四个button都没有被选中,flag=0;否则,flag=1.

希望能帮到楼主

this.radioButton1.CheckedChanged 注册此即可

安卓相对布局中radioGroup 中的2个radioButton控件如何并排放? 强行拉开后代码就从Group中分离

i++;

RadioButton TabIndex =

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="horizontal"/>

请帮我解释一下这段C#关于radiobutton的代码

android:checked="true"

private void button1_Click(object sender, EventArgs e)

{foreach (Control C in panel1.Controls)

}}

}这是一个按钮的点击

C is RadioButton 判断此次循环拿到的控件是不是RadioButton控件,这里的RadioButton是指控件类型 ((RadioButton)C)是强制转换,将Control控件转换为RadioButton控件

如果选中了,弹窗显示RadioButton的Text,即文本

panel1.Controls 包含很多控件 比如Lable 是lab{MessageBox.Show(C.Text);le类型

同理你这里的C可能不是RadioButton这个类型的控件,就没有Checked这个方法

android中的radiobutton要点击2下才能选中

Next

切换到哪一个的时候设置((RadioButton) findViewById(R.id.radiobutton)).setChecked(true);你试试看,或者判断一下

RadioButton TabIndex =

switch (radiogroup.getCheckedRadioButtonId()){

if (radioButton1.isChecked())

radioGroup2.clearCheck();

break;

case R.id.radio2:

if (radioButton2.isChecked())

radioGroup1.clearCheck();

break;

}

切换到哪一个的时候设置((RadioButton) findViewById(R.id.radiobutton)).setChecked(true);你试试看,或者判断一下

switch (radiogroup.getCheckedRadioButtonId()){

if (radioButton1.isChecked())

radioGroup2.clearCheck();

break;

case R.id.radio2:

if (radioButton2.isChecked())

radioGroup1.clearCheck();

break;

切换到哪一个的时候设置((RadioButton) findViewById(R.id.radiobutton)).setChecked(true);你试试看,或者判断一下

switch (radiogroup.getCheckedRadioButtonId()){

if (radioButton1.isChecked())

radioGroup2.clearCheck();

break;

case R.id.radio2:

if (radioButton2.isChecked())

radioGroup1.clearCheck();

break;

}

Android是基于Linux内核开发的作系统。主要面向及手持移动设备。

单击即指点中或触碰某程序或软件,单击后将会触发该程序运行。

而长按软件可以实现选中,单出可以选择的菜单。

对文件或者程序进行作,例如:移动、删除、拖拽等····

点击1下就可以,点击2下可能是你没点好。

Windows 窗体 RadioButton 控件为用户提供由两个或多个互斥选项组成的选项集。android中的RadioButton 也是一个意识,只不过需要使用一个RadioGroup包含起来,代表一组。

看看的设置是否有问题,单个RadioButton在选中后,通过点击无法变为未选中

要看你的点击选择是否正确setonclicklistener

wrm中自定义控件,有4radiobutton,如何定义个

{//当前控件是radiobutton,并且被选中

其实应该不用调用,你只要在radiobutton的选中中写你的逻辑就好了,用户选中的时候自动就会运行这段代码啊。

RadioButton radioButton = (RadioButton)findViewById(radioGroup.getCheckedRadioButtonId());

把名称写在这个后面就行了。然后在后台直接编辑这个名称就成了。OnCheckedChanged

可参考如下

c# radiobutton如何设置,我有3处都有radiobutton,但是选择其中一组的话,其他的就不能选了

你好,把需要互斥的几个radioButton放在同一个容器里就可以了,

radioButton可以使用很多的容器,这个容器可以是GroupBox, Panel, Form甚至是任何一个Control,只要他们的Parent是一样的就可以了.

现在都在form这个容器C is RadioButton 这句是判断循环得到的控件是RadioButton类型。才有Checked这个方法里

在web里很一行代码,控制子控件的排列方向。好办,有属性 GroupName 但是wrm里面必须放在容器里

请设置组

或者用radiobuttonlist控件

使用panel每一个radiobutton放在一个panel裏面

vb入门之分组控件:GroupBox控件

我们对控件进行分组的原因不外乎三个

为了获得清晰的用户界面而将相关的窗体元素进行可视化分组

编程分组 如对单选按钮进行分组

为了在设计时将多个控件作为一个单元来移动

在中 有GroupBox Panel TabControl这三个控件可以实现上面所提到的三个分组目的 所以我们称它们为分组控件

这三个控件在功用上十分的相似 特别是GroupBox和Panel控件 只存在一点细微的别而已(这个别是 只有GroupBox控件可以显示标题 而只有Panel控件可以有滚动条) 这里我们就先来了解GroupBox控件的使用

GroupBox(控件组)控件一般是作为其他控件的组的容器的形式存在的 这样有利于用户识别 使界面变得更加友好(GroupBox控件相当于Visual Basic以前版本的Frame控件) 使用控件组控件可以将一个窗体中的各种功能进一步进行分类 例如 将各种选项按钮控件分隔开

当移动单个GroupBox控件时 它所包含的所有控件也将一起移动

在大多数情况下 对控件组控件没有实际的作 我们用它对控件进行分组 通常没有必要响应它的 不过 它的Name Text和Font等属性可能会经常被修改 以适应应用程序在不同阶段的要求

GroupBox控件在工具箱中的图标如图所示

一 GroupBox控件的常用属性

Anchor和Dock 这两个属性是所有有用户界面的控件都有的属性 这里就不啰嗦了

Nthis.radioButton1.Checked == true 就是说这个btn被选中了ame属性 标识控件的对象名称

Text属性 显示在GroupBox控件右上方的标题文字 可以用来标识该控件组的描述

Font和ForeColor属性 用于改变GroupBox控件的文字大小以及文字的颜色 需要注意的时候 它不单改变GroupBox控件的Text属性的文字外观 同时也改变其内部控件的显示的Text属性的文字外观

二 创建一组控件

在窗体上放置GroupBox控件 从工具箱中拖放一个GroupBox控件到窗体上的合适位置 调整大小

在属性窗口中改变GroupBox控件的Text属性 作为它的标题

在GroupBox控件内拖放其它需要的控件 例如RadioButton控件

设置示例 如图一所示

图一 用控件组控件对单选按钮分组

我们在拖动单个GroupBox控件的时候 它内部的控件也会随着移动 以保持和GroupBox的相对位置不变 同理 删除GroupBox控件时 它所包含的所有控件也会被删除掉

当我们调整GroupBox控件所包含的控件的Anchor和Dock属性的时候 其参照物将不是Form窗体 而是GroupBox控件了

三 编程添加GroupBox控件以及它所包含的控件

虽然GroupBox控件是在设计时用视图设计布局效果 但是无可避免地 很多特殊情况下也是需要在运行做添加控件到控件组中的 这里我们就用代码来完成上图一界面的绘制

动态添加控件一般需要经过下面三个步骤

创建要添加的控件实例

设置新控件的属性

将控件添加到父控件的 Controls

Sub InitializeControl()

首先添加Label和TextBox控件

Dim Label As New System Windows Forms Label

Dim TextBox As New System Windows Forms TextBox

Label

Label Location = New System Drawing Point( )

Label Name = Label

Label Size = New System Drawing Size( )

Label TabIndex =

Label Text = 户主姓名

TextBox

TextBox Location = New System Drawing Point( )

TextBox Name = TextBox

TextBox Size = New System Drawing Size( )

TextBox TabIndex =

TextBox Text =

把它们添加到父控件Form 的Controls中

Me Controls Add(TextBox )

Me Controls Add(Label )

添加三个GroupBox控件

Dim GroupBox As New System Windows Forms GroupBox

Dim GroupBox As New System Windows Forms GroupBox

Dim GroupBox As New System Windows Forms GroupBox

GroupBpublic class E extends JFrame implements ItemListener{ox

GroupBox BackColor = System Drawing SystemColors Control

GroupBox Location = New System Drawing Point( )

GroupBox Size = New System Drawing Size( )

GroupBox TabIndex =

GroupBox TabStop = False

GroupBox Text = 性别

GroupBox

GroupBox Location = New System Drawing Point( )

GroupBox Size = New System Drawing Size( )

GroupBox TabIndex =

GroupBox TabStop = False

GroupBox Text = 单元

GroupBox

GroupBox Location = New System Drawing Point( )

GroupBox Size = New System Drawing Size( )

GroupBox TabIndex =

GroupBox TabStop = False

GroupBox Text = 楼层

把它们添加到父控件Form 的Controls中

Me Controls Add(GroupBox )

Me Controls Add(GroupBox )

Me Controls Add(GroupBox )

添加RadioButton控件并分别绘制在GroupBox控件内

Dim RadioButton As New System Windows Forms RadioButton

Dim RadioButton As New System Windows Forms RadioButton

Dim RadioButton As New System Windows Forms RadioButton

Dim RadioButton As New System Windows Forms RadioButton

Dim RadioButton As New System Windows Forms RadioButton

Dim RadioButton As New System Windows Forms RadioButton

Dim RadioButton As New System Windows Forms RadioButton

Dim RadioButton As New System Windows Forms RadioButton

Dim RadioButton As New System Windows Forms RadioButton

Dim RadioButton As New System Windows Forms RadioButton

RadioButton Location = New System Drawing Point( )

RadioButton Name = RadioButton

RadioButton Size = New System Drawing Size( )

RadioButton Text = 男性

RadioButton Location = New System Drawing Point( )

RadioButton Name = RadioButton

RadioButton Size = New System Drawing Size( )

RadioButton Text = 女性

RadioButton Location = New System Drawing Point( )

RadioButton Name = RadioButton

RadioButton Size = New System Drawing Size( )

RadioButton Text = 二单元

RadioButton Location = New System Drawing Point( )

RadioButton Name = RadioButton

RadioButton Size = New System Drawing Size( )

RadioButton Text = 三单元

RadioButton Location = New System Drawing Point( )

RadioButton Name = RadioButton

RadioButton Size = New System Drawing Size( )

RadioButton BackColor = System Drawing SystemColors Control

RadioButton Location = New System Drawing Point( )

RadioButton Name = RadioButton

RadioButton Size = New System Drawing Size( )

RadioButton Text = 四单元

RadioButton Location = New System Drawing Point( )

RadioButton Name = RadioButton

RadioButton Size = New System Drawing Size( )

RadioButton Text = 二楼

RadioButton Location = New System Drawing Point( )

RadioButton Name = RadioButton

RadioButton Size = New System Drawing Size( )

RadioButton Text = 三楼

RadioButton Location = New System Drawing Point( )

RadioButton Name = RadioButton

RadioButton Size = New System Drawing Size( )

RadioButton Text = 一楼

RadioButton BackColor = System Drawing SystemColors Control

RadioButton Location = New System Drawing Point( )

RadioButton Name = RadioButton

RadioButton Size = New System Drawing Size( )

RadioButton Text = 四楼

分别把它们添加到父控件GroupBox的Controls中

GroupBox Controls Add(RadioButton )

GroupBox Controls Add(RadioButton )

GroupBox Controls Add(RadioButton )

GroupBox Controls Add(RadioButton )

GroupBox Controls Add(RadioButton )

GroupBox Controls Add(RadioButton )

GroupBox Controls Add(RadioButton )

GroupBox Controls Add(RadioButton )

GroupBox Controls Add(RadioButton )

GroupBox Controls Add(RadioButton )

End Sub

把上一页的代码添加后 把控件初始化过程InitializeControl()过程添加到Form 的New构造函数中 如下图二所示

图二 在New构造函数中添加过程InitializeControl()

现在按F 运行 Form 的窗体控件布局(如下图三所示)是不是和我们手工布局的图一的布局是一样的呢?

lishixinzhi/Article/program/ASP/201311/21749

JAVA中JRadioButton控件怎么样获取选择值

import ja.awt.nt.;

给你个例子,你看看吧,有什么问题再问我:

import jax.swing.;

import ja.awt.;

JPanel jp=new JPanel();

JTextArea ja=new JTextArea("文本框",12,12);

JScrollPane jsp=new JScrollPane(ja);

JRadioButton radiobutton;// 单选框

E(){

super("JRadioButton Test");

radiobutton = new JRadioButton("单选框");

Container con= this.getContentPane();

con.setLayout(new GridLayout(3,1));

// 添加单GroupBox Name = GroupBox选框

con.add(radiobutton);

radiobutton.setLocation(160, 110);

radiobutton.setSize(100,120);

radiobutton.addItemListener((ItemListener) this);

//将JtextArea加到容器中

jp.add(jsp);

setSize(300, 200);;

this.setLocation(300, 300);

setVisible(true);

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}public void StateChanged(ItemEvent e) {

if(e.getSource()==radiobutton){

JRadioButton jrb=(JRadioButton)e.getSource();

if(jrb.isSelected()){

ja.setText(jrb.getText());

}else{

ja.setText("");

}}

}public static void main(String[] args) {

new E();

}}

可以试一下getText()成员,父类的一个函数!

解释radiobutton控件的checked属性 、groupname属性和checkedchanged的作用?

checked属性为TRUE表示是当前选 中项。。。指定多个radiobutton选项的groupname相同,表示这些radiobutton为同一个组。也就是只能选con.add(jp);单个。。。

checkedchanged看if (mMale.getId() == checkedId) {名字,就是在选中项改变的时候会触发该。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 12345678@qq.com 举报,一经查实,本站将立刻删除。

联系我们

工作日:9:30-18:30,节假日休息