There are some items already present in my listView . There is an add button on the page that opens an dialog where user can add a new item. Once the dialog closes I have to append that new item with already existing item. Here is the code and it goes till end but the new item is not added. i have multiple columns in my list view.What i am doing wrong in this.
public frmEditObject(AddException ObjException)
{
InitializeComponent();
if (ObjException != null)
{
ListViewItem lviMember, lviSender = null;
bool alreadyExists =
exceptionsList.Find(
item =>
item.UserDetail == ObjException.UserDetail && item.ExceptionType != ObjException.ExceptionType) !=
null
? true
: false;
if (!alreadyExists)
{
exceptionsList.Add(ObjException);
lvwExceptionMember.Items.Clear();
lvwExceptionMember.BeginUpdate();
foreach (var item in exceptionsList)
{
if (item.ExceptionType == Enumerations.ExceptionType.Members)
{
lviMember = new ListViewItem(
item.UserDetail);
lviMember.Tag = 0;
lviMember.SubItems.Add(GetDisplayNameFromSamAccountName(item.UserDetail));
lvwExceptionMember.Items.Add(lviMember);
}
}
lvwExceptionMember.EndUpdate();
lvwExceptionMember.Refresh();
}
}
}
Follow these steps: