C#小白 求大神打救

q342919294 2014-04-26 09:30:16
刚学C#不久 求大神教教我这个小白如何将Combobox里面的值传到Listbox里面,并且Combobox里各项的值只能传一次。
比如我combobox里添加的值是苹果 香蕉 西瓜 ,那么苹果 香蕉 西瓜传到listbox里就只能传一次

求大神教教我
...全文
346 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
PaulyJiang 2014-04-30
  • 打赏
  • 举报
回复
引用 4 楼 wind_cloud2011 的回复:

     for (int i = 0; i < comboBox1.Items.Count; i++)
            {
                if (!listBox1.Items.Contains(comboBox1.Items[i]))
                {
                    listBox1.Items.Add(comboBox1.Items[i]);  
                }
            }


+10086
水目 2014-04-29
  • 打赏
  • 举报
回复
引用 4 楼 wind_cloud2011 的回复:

     for (int i = 0; i < comboBox1.Items.Count; i++)
            {
                if (!listBox1.Items.Contains(comboBox1.Items[i]))
                {
                    listBox1.Items.Add(comboBox1.Items[i]);  
                }
            }


+1
祥子爱游戏 2014-04-29
  • 打赏
  • 举报
回复
遍历foreach||for
zzyhost 2014-04-28
  • 打赏
  • 举报
回复
我看成了求大神打败
wind_cloud2011 2014-04-26
  • 打赏
  • 举报
回复

     for (int i = 0; i < comboBox1.Items.Count; i++)
            {
                if (!listBox1.Items.Contains(comboBox1.Items[i]))
                {
                    listBox1.Items.Add(comboBox1.Items[i]);  
                }
            }


threenewbee 2014-04-26
  • 打赏
  • 举报
回复
Listbox1.Items.Clear();
foreach (string s in ComboBox1.Items)
{
ListBox1.Items.Add(s);
}

110,535

社区成员

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

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

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