how to add data to a Listview?

1
private void button1_Click(object sender, EventArgs e)
{
    ListViewItem lista = new ListViewItem(textBox1.Text);
    lista.SubItems.Add = (textBox2.Text);
    lista.SubItems.Add = (textBox3.Text);
    listView1.Items.Add(lista);

    listView1.Items.Add(lista);
}

This is supposed to be the correct way, but it gives me an error in lista.SubItems.Add because it says I can not add "add", because it is a group of methods

    
asked by alevin_sensei 13.06.2018 в 08:15
source

1 answer

1

Add is not a property, but a method. This means that you can not "assign" a value to add, you must execute the method by passing the item to be added as a parameter.

private void button1_Click(object sender, EventArgs e)
{
    ListViewItem lista = new ListViewItem(textBox1.Text);
    lista.SubItems.Add(textBox2.Text);
    lista.SubItems.Add(textBox3.Text);
    listView1.Items.Add(lista);
}
    
answered by 13.06.2018 в 08:50