Many times I forget, how to Load data in ListView Control. I think many person fell like me.
So I need to publish the usage with code sample
void LoadErrors()
{
lvwErrors.Columns.Clear();
lvwErrors.Columns.Add("ErrorCode");
lvwErrors.Columns.Add("ErrorSource");
lvwErrors.Columns.Add("ErrorDescription");
lvwErrors.View = View.Details;
lvwErrors.Items.Clear();
List
ListViewItem item= null;
foreach (ErrorObject error in errors)
{
item = new ListViewItem(error.ErrorCode.ToString());
item.SubItems.Add(error.ErrorSource);
item.SubItems.Add(error.ErrorDescription);
lvwErrors.Items.Add(item);
}
}
No comments:
Post a Comment