| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1664 人关注过本帖
标题:获取一组radiobutton选中项
只看楼主 加入收藏
shenhaoli
Rank: 1
等 级:新手上路
帖 子:24
专家分:2
注 册:2010-4-15
结帖率:75%
收藏
 问题点数:0 回复次数:4 
获取一组radiobutton选中项
获取一组radiobutton选中项只能用遍历的方法吗???
搜索更多相关主题的帖子: radiobutton 获取 
2010-04-19 15:31
不说也罢
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:39
帖 子:1481
专家分:4989
注 册:2007-10-7
收藏
得分:0 
假定Form1中有一个分组GroupBox1:

        Dim a As Control
        For Each a In Me.GroupBox1.Controls
            If TypeOf a Is RadioButton Then MsgBox(a.Text)
        Next

其它的你可以举一反三了

===================================================
讨厌C#的行尾的小尾巴;和一对大括号{ }
===================================================
2010-04-19 17:05
shenhaoli
Rank: 1
等 级:新手上路
帖 子:24
专家分:2
注 册:2010-4-15
收藏
得分:0 
用中间量
很冷清,又想到了一个方法,用中间量
用一个中
程序代码:
Public Class frmradiobutton

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Me.Close()
    End Sub

    Private Sub frmradiobutton_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Rad1.Checked = True
        Radxb1.Checked = True
    End Sub

    Private Sub Rad1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Rad1.CheckedChanged
        TextBox1.Text = Rad1.Text
    End Sub

    Private Sub Rad2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Rad2.CheckedChanged
        TextBox1.Text = Rad2.Text
    End Sub

    Private Sub Rad3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Rad3.CheckedChanged
        TextBox1.Text = Rad3.Text
    End Sub

    Private Sub Radxb1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Radxb1.CheckedChanged
        TextBox2.Text = Radxb1.Text
    End Sub

    Private Sub radxb2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radxb2.CheckedChanged
        TextBox2.Text = radxb2.Text
    End Sub
End Class
间量存储每组控件的状态,当CheckedChanged改变该中间量,下面的例子我用的是textbox控件
2010-04-19 17:21
shenhaoli
Rank: 1
等 级:新手上路
帖 子:24
专家分:2
注 册:2010-4-15
收藏
得分:0 
谢谢
2010-04-19 17:22
sywzs
Rank: 10Rank: 10Rank: 10
来 自:辽宁
等 级:贵宾
威 望:15
帖 子:508
专家分:1725
注 册:2009-5-13
收藏
得分:0 
简化一下代码,第3、4、5段合并为
    Private Sub Rad1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Rad1.CheckedChanged, Rad2.CheckedChanged, Rad3.CheckedChanged
        TextBox1.Text = sender.Text
    End Sub

第6、7段合并为
    Private Sub Radxb1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Radxb1.CheckedChanged, radxb2.CheckedChanged
        TextBox2.Text = sender.Text
    End Sub
2010-04-20 13:58
快速回复:获取一组radiobutton选中项
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.031394 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved