问题是从列表中删除列表项之后,但是每当用户尝试输入另一个列表项时,删除的项目都会返回列表。
我真的是C#的新手。很感谢任何形式的帮助。 这是我的代码。
int index = 0;
string [,] item = new string[10000,10];
private void add() // THIS IS FOR THE ADD BUTTON
{
item[index, 0] = maskID.Text;
item[index, 1] = txtLName.Text;
item[index, 2] = txtFName.Text;
item[index, 3] = maskContact.Text;
item[index, 4] = txtAddress.Text;
item[index, 5] = cmbCourse.Text;
item[index, 6] = cmbYear.Text;
index++
listDorm.Items.Clear();
for (int i = 0; i < index; i++)
{
ListViewItem word = new ListViewItem();
word.Text = item[i, 0];
word.SubItems.Add(item[i, 1]);
word.SubItems.Add(item[i, 2]);
word.SubItems.Add(item[i, 3]);
word.SubItems.Add(item[i, 4]);
word.SubItems.Add(item[i, 5]);
word.SubItems.Add(item[i, 6]);
listDorm.Items.Add(word);
Clear(); //THIS IS TO CLEAR ALL THE TEXTBOXES IN REGISTRATION FORM
}
}
private void Delete() //THIS IS FOR DELETING ITEMS
{
DialogResult delItem;
delItem = MessageBox.Show("Are you sure you want to delete this?", "Remove Item", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (delItem == DialogResult.Yes)
listDorm.Items.RemoveAt(listDorm.SelectedIndices[0]);
Clear();
}
}
}