开发者

Listbox Count error

开发者 https://www.devze.com 2023-04-02 09:40 出处:网络
I\'m receiving an error on the 5th line, listCell.Count() tried resolving it with listCell.Items.Count() but that didn\'t work... any idea? error: does not contain a 开发者_如何学Pythondefinition for

I'm receiving an error on the 5th line, listCell.Count() tried resolving it with listCell.Items.Count() but that didn't work... any idea? error: does not contain a 开发者_如何学Pythondefinition for count.

        int listCellCounter = 0;
        for (int x = 0; x < listId.Items.Count; x++)
        {
            Console.WriteLine("something " + listId.Items[x] + " " + listCell.Items[listCellCounter]);
            if (listCellCounter == listCell.Count() - 1)
            {
                listCellCounter = 0;
            }
            else
            {
                listCellCounter += 1;
            }
        }


Im not quite sure what collection the listCell is but I'd imagine that .Count() should be a property. So try to change your code to this:

    ...

    if (listCellCounter == listCell.Count - 1) // or listCell.Items.Count - 1
    { 
        listCellCounter = 0;
    }

    ...

The error you are getting basicly just means that there is no Count() method in listCell.

0

精彩评论

暂无评论...
验证码 换一张
取 消