繁体   English   中英

C#从我的form2中获取form1中我的复选框列表中的项目

[英]c# getting items of my checkedboxlist in form1 from my form2

我正在尝试从form2获取form1中我的checkboxboxlist中的项目。

我的确把form1.checkedboxlist MODIFIER的属性放到PUBLIC

我可以到达清单,但是里面没有物品。 当我使用checkedboxlist.items.count时,它告诉我列表中什么都没有,但这不是真的

string[] list = new string[form1.ckdBoxList.Items.Count];

MessageBox.Show(list.Length.ToString());//In debug it tells me that the lenght is 0

for (int i = 0; i <= list.Length; i++)
{
   list[i] = fenPrincipal.ckdBoxList.Items[i].ToString();
}

谢谢您的帮助

试试看

    string[] list = new string[form1.ckdBoxList.Items.Count];

    MessageBox.Show(form1.ckdBoxList.Items.Count+"");//In debug it tells me that the lenght is 0

    for (int i = 0; i < form1.ckdBoxList.Items.Count; i++)
    {
        list[i] = form1.ckdBoxList.Items[i].ToString();
    }

这是指向非常相似的问题和我提供的解决方案的两个链接。

解决方案选项1

另外一个选项

暂无
暂无

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

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