Problem with adding Item to a ListView
Hey,
i've Problems with adding Item's to my listView1 because its in a Static Function.
Here how i try it:
Code:
int[] myItems = new int[]
{
GetName(i), // this one is a String
GetCount(i),
GetLevel(i),
GetMinBid(i),
GetMinIncrement(i),
GetBuyoutPrice(i),
GetBidAmmount(i),
GetOwner(i) // this one is a String
};
ListViewItem lvi = new ListViewItem(myItems);
listView1.Items.Add(lvi); //listView1 is red marked because its not Static!
hope someone can help me with it.
Re: Problem with adding Item to a ListView
your question is a bit vague mate
for starters the problem that i see here is that you are trying to pass int[] to the ListVieIitem constructor and you can't do that, ListVieIitem doesn't take int[] at least not on VS2005 which is the compiler im using but it does take string[] so you might want to start there.
Second, Where do you get the idea that the the problem here is that listview1 is is not static?
what compiler are you using that is giving you that message? and are you sure listview1 already exist?
and lastly what are you trying to do here:
Code:
{
GetName(i), // this one is a String
GetCount(i),
GetLevel(i),
GetMinBid(i),
GetMinIncrement(i),
GetBuyoutPrice(i),
GetBidAmmount(i),
GetOwner(i) // this one is a String
};
looks like you are trying to populate the array using private functions all within a loop and if that is the case why are you trying to add strings to an int array?
Re: Problem with adding Item to a ListView
Make the function not static, or pass the listView to it as an argument.