【发布时间】:2012-01-10 17:45:43
【问题描述】:
我正在使用 do-while 循环来获取列表框的每个项目。
我的代码示例如下:
do
{
string nameOfPersonFromWeb;
//Here is code that do some task from web
//for eg. get the name list from the website...
ListBox.Items.Add(nameOfPersonFromWeb);
totalnumber++;
} while (totalNumber<=25);
我的问题是,我没有立即得到每件物品。当循环结束时,它会显示整个项目。
我想在列表框中的每个循环中显示名称。我还想通过发送列表框项的索引来突出显示特定的列表框项。我在代码后面和 Asp.net 中使用 C#。
【问题讨论】:
-
@DJ KRAZE:因为至少有一次我必须进入循环。
-
您应该使用 for 循环也请发布您分配 nameOfPersonFromWeb 的代码部分
-
如果你必须至少输入一次,我想看看你在哪里分配 nameOfPersonFromWeb.. 你能粘贴完整的方法吗..
-
为什么不填充您的集合,然后将 ListBox.ItemsSource 设置为新集合?
-
@DJ KRAZE:我不能分享其他代码,因为它是机密的。我的问题就像我在上面的问题中所说的那样。我的代码的所有其他部分都很好。
标签: c# asp.net listbox do-while