C#中如何将textbox中查到的值的全部信息传给listview控件中
2个回答
展开全部
private void button1_Click(object sender, EventArgs e)
{
addlist(textBox1.Text.Trim(), textBox2.Text.Trim(), textBox3.Text.Trim());
}
public void addlist(string id,string name,string grade)
{
ListViewItem item = new ListViewItem(new string[] { id ,name , grade }, 0);
foreach(ListViewItem t in listView1.Items)
{
if (t.SubItems[0].ToString() == item.SubItems[0].ToString())
{
MessageBox.Show("已有");
return ;
}
}
listView1.Items.Add(item);
}
{
addlist(textBox1.Text.Trim(), textBox2.Text.Trim(), textBox3.Text.Trim());
}
public void addlist(string id,string name,string grade)
{
ListViewItem item = new ListViewItem(new string[] { id ,name , grade }, 0);
foreach(ListViewItem t in listView1.Items)
{
if (t.SubItems[0].ToString() == item.SubItems[0].ToString())
{
MessageBox.Show("已有");
return ;
}
}
listView1.Items.Add(item);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询