2012-04-25 22 views
0

我試圖從form2中獲取Form1中checkedboxlist中的項目。c#從form2中獲取formbox1中checkedboxlist的項目

我也把我的form1.checkedboxlist改性劑的propertie到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(); 
} 

感謝你的幫助

+1

是Form1中仍然開放,可見當您切換到FORM2? – mellamokb 2012-04-25 17:35:53

回答

0

嘗試用

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(); 
    } 
+0

非常感謝你 – pharaon450 2012-05-23 18:04:09

相關問題