[英]How to keep the checkbox checked in DatagridView Checkbox vb.net
[英]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.