Hi all,
I have an ArrayList that contains 70 items. I would like to display these items in Listview. Therefore, I used the following code.
However, When I press the button, program will only display the first seven items in the arrayList. The rest of items are not being displayed in listview.
How can I fix this problem ?
Cheers,
------------BEGIN---------------
private void btn_CreateReport_Click(object sender, EventArgs e)
{
lstview.Items.Clear();
int counterOfArraylist = mcarraylist.Count;
string[] str = new string[counterOfArraylist];
for (int i = 0; i < str.Length; i++)
{
str[i] = mcarraylist[i].ToString();
}
lstview.Items.Add(new ListViewItem(str));
}
------------END---------------
How can i display these items in Listview in C#?
Started by april.zoom, Apr 08 2010 10:47 AM
1 reply to this topic
#1
Posted 08 April 2010 - 10:47 AM
|
|
|
#2
Posted 08 April 2010 - 07:36 PM
I guess you have to use the lstview.Items.Add inside the for loop
private void btn_CreateReport_Click(object sender, EventArgs e)
{
lstview.Items.Clear();
int counterOfArraylist = mcarraylist.Count;
string[] str = new string[counterOfArraylist];
for (int i = 0; i < str.Length; i++)
{
str[i] = mcarraylist[i].ToString();
lstview.Items.Add(new ListViewItem(str[i]));
}
}
Try this, Hopefully, it might work...


Sign In
Create Account

Back to top









