簡體   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