[Solved] c# Add listView items from another form [closed]


The error is in the function

 public void AddItem(object value)
 {
     listView1.Items.Add(value);
 }

you pass an object to this function and try to add it to the ListViewItemCollection, but there is no overload of the Add method of the ListViewItemCollection that accepts an object

Change it to

 public void AddItem(string value)
 {
     listView1.Items.Add(value);
 }

This will solve the immediate compilation problem, but you will have hard time working with that static variable. If your plan were to pass values from form2 to form1 it is better that you keep the created instance of form1 and use it to pass values through the AddItem method otherwise you will end to add that values to other instances of the Form1 (the latter instance created will receive the new string)

1

solved c# Add listView items from another form [closed]