josip
josip

Reputation: 300

Filling listView columns with different arrays in C#

Suppose I have three arrays-

public bool[] A = { false, false, false, false, true, true, true, true };
public bool[] B = { false, false, true, true, false, false, true, true };
public bool[] X = { false, true, false, true, false, true, false, true };

And an empty listView named lvTAB. Is there a way to fill the first column in listView with the values of the first array,second and third respectively?

Upvotes: 0

Views: 230

Answers (1)

apomene
apomene

Reputation: 14389

int i=0;
foreach (bool b in A)
{
        string[] row = { b.ToString(), B[i].ToString(), X[i].ToString() };
        var listViewRow = new ListViewItem(row); 
        listView1.Items.Add(listViewRow);
        i++;
}

Upvotes: 1

Related Questions