I am new to c#. In my project I have two controls ListBox and ListView
ListBox --> lbxEmpName
ListView --> lvEmpDetails
I tried the below code:
if (lvEmpDetails.Items.Count > 0)
{
for (int intCount = 0; intCount < lbxEmpName.Items.Count; intCount++)
{
for (int intSubCount = 0; intSubCount < lvEmpDetails.Items.Count; intSubCount++)
{
if (lvEmpDetails.Items[intSubCount].Equals(lbxEmpName.Items[intCount]))
{
lbxEmpName.Items.Remove(lbxEmpName.Items[intCount]);
}
}
}
}
If I run the above code, there are no matches between ListView Items and ListBox Items (Infact there must be some matches). When I debug my code, I saw the below thing: It is saying SelectedItem whereas I am giving here Items (Thats why my program is not matching items)
why it is showing SelectedItem = "" instead of Items ?
Am I doing something wrong in my code? Please suggest.


ListView’s
Itemscontains objects of typeListViewItem. So there is no use in comparing those with objects in ListBox’sItems.If you want to compare their text, you must write something like this:
Please note that a
ListViewItemcan have multiple sub-items and itsTextproperty returns the first column of its data.