开发者

Listbox items overflow

开发者 https://www.devze.com 2023-03-01 19:59 出处:网络
Whenever I use a for loop so select each item in the Listbox Using Listbox.SetSelected(i) it overflows over the Listb开发者_Python百科ox. anyone has a solution?Since you mention for and overflow, I as

Whenever I use a for loop so select each item in the Listbox Using Listbox.SetSelected(i) it overflows over the Listb开发者_Python百科ox. anyone has a solution?


Since you mention for and overflow, I assume the problem is an index range; most .NET indexers are 0-based, so you need:

for(int i = 0 ; i < collection.Length ; i++)
{
    collection[i].DoSomething();
}

Note also that in most cases foreach is simpler and safer:

foreach(var item in collection)
{
    item.DoSomething();
}
0

精彩评论

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