求助

bethrezen 2003-03-31 03:44:21
当选中ListBox中的一个item,点击Select按钮时,item被加入一个类(内存?),同时,textBox1显示1,再次选中ListBox中的一个item,点击Select按钮,一个item被加入同一个类(内存?),同时,textBox1显示2;依次类推,点击一个item,textBox1就加1,item可以为同一个item.
...全文
35 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
bethrezen 2003-04-02
  • 打赏
  • 举报
回复
谢谢了!
Knight94 2003-04-01
  • 打赏
  • 举报
回复
Sorry,把最后一句改为textBox1.Text=arrItem.Count.ToString();

整体如下:
ArrayList arrItem=new ArrayList();
Select按钮点击事件如下:
arrItem.Add(listBox1.SelectedItem.ToString());
textBox1.Text=arrItem.Count.ToString();
bethrezen 2003-04-01
  • 打赏
  • 举报
回复
分可以再加。
Knight94 2003-04-01
  • 打赏
  • 举报
回复
你的ArrayList作为全局的或Form的成员,而不要每次在按钮点击事件中再定义一个,这样就行了。
bethrezen 2003-04-01
  • 打赏
  • 举报
回复
to Knight94:
按你的方法,textBox1显示只是1,不增加!
bethrezen 2003-03-31
  • 打赏
  • 举报
回复
Cannot implicitly convert type 'int' to 'string'
Knight94 2003-03-31
  • 打赏
  • 举报
回复
ArrayList arrItem=new ArrayList();
Select按钮点击事件如下:
arrItem.Add(listBox1.SelectedItem.ToString());
textBox1.Text=arrItem.Count;
bethrezen 2003-03-31
  • 打赏
  • 举报
回复
Cannot convert type 'string' to 'int'
seabirdforever 2003-03-31
  • 打赏
  • 举报
回复
其实你可以在select 按钮的click事件里面 把 textBox1的text转化成 int型 ,然后加1
最后在 转化成 string 赋值给 textBox1.text

textBox1.text =(string)((int)textBox1.text+1)

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧