0

I`m trying to get the items in of my checkedboxlist that is in form1 from my form2.

I did put the propertie of my form1.checkedboxlist MODIFIER to PUBLIC

I can reach the list but i can`t get the items inside. When i used the checkedboxlist.items.count it tells me there is nothing in my list but it is not true

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

thank you for your help

SuperOli
  • 1,784
  • 1
  • 11
  • 23
pharaon450
  • 493
  • 3
  • 9
  • 21

2 Answers2

0

Try with

    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();
    }
sarwar026
  • 3,821
  • 3
  • 26
  • 37
0

Here' are two links to very similar questions asked and solutions I've offered them.

Solution option 1

Another option

Community
  • 1
  • 1
DRapp
  • 47,638
  • 12
  • 72
  • 142