用法一:ListView控件添加、移除项目
1.控件
listView控件、button控件、textBox控件
示例:
2.方法
三个按钮的方法
示例:
private void btnAdd_Click(object sender, EventArgs e)
{
if (txtAdd.Text == "")
{
MessageBox.Show("不能为空");
}
else
{
litCountry.Items.Add(txtAdd.Text.Trim());
}
txtAdd.Text = "";
txtAdd.Focus();
}
private void btnRemove_Click(object sender, EventArgs e)
{
if (litCountry.SelectedItems.Count == 0)
{
MessageBox.Show("请选择移除项目");
}
else
{
litCountr