ListBox不会显示所有项目 [英] ListBox does not show all items

查看:170
本文介绍了ListBox不会显示所有项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在做一个简单的任务,向列表框显示一些字符串.
问题是;如果我将5个项目(字符串)添加到列表框中,它将在5行中显示第一个添加的项目.我希望它显示所有添加的项目.

以下是我的代码:

Hi guys,

i was working on a simple task to show some strings to the listbox.
The problem is; if i add 5 items(string) to the listbox, it shows the 1st added item in 5 rows. I want it to show all the added items.

Below is my code:

for (int i = 1; i <= 5; i++)
{
   for (int i = 0; i < 7; i++)
   {
      int iDraw = randomNum.Next(1, 1000000);
      ListNumContainer.Add(iDraw);
   }
   for(int i = 0; i < ListNumContainer.Count; i++)
   {
        strBlder.AppendFormat(Convert.ToString(ListNumContainer[i]));
        if(i!=5)
          strBlder.Append("-");
   }
   listBox.Items.Add(strBlder);
}



ListNumberContainer包含一些int,并将在添加到listBox之前追加到stringbuilder.

有什么我想念的吗?
ListBox,ListBoxItem,ListView和ListViewItem有什么区别?

谢谢,
Skunkhead:)



The ListNumberContainer contains some int and will be appended to the stringbuilder before added to the listBox.

Is there anything which i have missed out?
And what is the difference between ListBox,ListBoxItem,ListView and ListViewItem?

Thanks,
Skunkhead :)

推荐答案

感谢大家的所有评论和答复.赞赏.

此问题是由于StringBuilder对象声明为全局变量引起的.我已将其更改为局部变量,从而解决了该问题.

Thanks guys for all your comments and reply. Appreciate it.

This problem was due to StringBuilder object declared as global variable. I have change it to be a local variable and this fix the problem.

Thx.


我可以看到在嵌套在一起的两个循环中使用的控制变量"i".这是一个错误

另外,请查看页面.您可以更正HTML实体的格式吗-很难阅读.查看此页面的编辑框-它具有允许HTML",转义HTML字符"等选项.

ListBox,ListBoxItem,ListView和ListViewItem之间有什么区别?好吧,大约和苹果和芭蕾舞演员之间的区别相同.
严重的是,Microsoft提供了很好的文档.只需阅读和理解它们,甚至比提出问题要花得多的钱(当然,或多或少是正确的方式,所以任何人都可以自愿回答).
I can see control variable "i" used in two loops nested into each other. It''s a mistake

Also, please look at the page. Could you correct formatting of HTML entities -- hard to read. Look at this page''s edit box -- it has options like "allow HTML", "escape HTML characters", etc.

And what is the differences between ListBox,ListBoxItem,ListView and ListViewItem? Well, approximately the same as the difference between apple and ballerina.
Seriously, Microsoft provides very good documentation on those. Just reading and understanding them will cost you much less than even formulating your questions (of course, in more or less correct way, so anyone would volunteer to answer).


这篇关于ListBox不会显示所有项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆