繁体   English   中英

如何在Vb.Net中获取Checked CheckBox标记值?

[英]How to get Checked CheckBox tag value in Vb.Net?

我分别在GroupBox1, 2, 3中将一些复选框GroupBox1, 2, 3 现在,我想知道复选框的标签值(我正在使用TAG property为单选按钮分配一些值),该复选框在两个组框中都已选中。

除了使用if then语句,还有其他解决方案吗?

遍历组框组件并检查哪些是复选框。 然后,检查其“已Checked状态或您想要执行的任何操作。

C#示例:

foreach (Control c in groupBox1.Controls)
{
    if (c is CheckBox && ((CheckBox)c).Checked)
    {
        // whatever
    }
}

VB.NET示例:

For Each c As Control In groupBox1.Controls
    If TypeOf c Is CheckBox AndAlso DirectCast(c, CheckBox).Checked Then
        ' Whatever
    End If
Next

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM