Winform中获得多个CheckBox的Tag,Text,并把得到的多个tag,Text之间用逗号分开

xiaoxinxin1128 2013-07-26 05:02:35
Winform窗体中,有多个CheckBox,现在要拿到选中的checkbox的Tag和text,并把拿到的tag和text分别用逗号隔开?
...全文
56 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
laisui 2013-07-26
  • 打赏
  • 举报
回复
ArrayList al = new ArrayList();
        void getCBTagAndText()
        {
            al.Clear();
            foreach (Control c in this.Controls)
            {
                if ((c as CheckBox) != null)
                {
                    if (c.Tag != null)
                        al.Add(c.Tag.ToString() + "," + c.Text);
                    else
                        al.Add("null," + c.Text);
                }
            }
        }

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧