Click to See Complete Forum and Search --> : ListView Errors! Help!


functor
April 8th, 2005, 01:02 PM
Hey!

I'm new to the whole windows programming scene. I'm making an app that pretty much displays information thats stored in a couple classes I built. The classes worked fine when tested in a console program. I was able to get a lot of information already from this site, and I think I'm quite close (may not be tho).

The error im getting @ build time is:
Form1.h(127): error C2691: 'System::String' : invalid type for __gc array element

For all my classes, all the data members are public for now. I also use char arrays instead of Strings in my classes. Any ideas on how to fix my problems? I'd appreciate any advice anyone has. Thanks!


private: System::Void listView1_SelectedIndexChanged(System::Object * sender, System::EventArgs * e)
{
bingomonitor bm;
bm.getBingoHalls();
String* ItemObject1[] = __gc new String[5];

for (int i = 0; i < bm.numHalls; i++)
{
ListViewItem *items = new ListViewItem(S"helal",0);

ItemObject1[0] = String(bm.halls[i].hallCode);
ItemObject1[1] = String(bm.halls[i].hallName);
ItemObject1[2] = String(bm.halls[i].stationID);
ItemObject1[3] = String(bm.halls[i].stationName);
ItemObject1[4] = String(bm.halls[i].hallStatus);

listView1->Items->Add(ItemObject1[0],5);
listView1->Items->Item[i]->SubItems->Add(ItemObject1[1]);
listView1->Items->Item[i]->SubItems->Add(ItemObject1[2]);
listView1->Items->Item[i]->SubItems->Add(ItemObject1[3]);
listView1->Items->Item[i]->SubItems->Add(ItemObject1[4]);
}
}

dumbquestion
April 8th, 2005, 04:42 PM
I think this is the way to declare an array of String* 's

String* stringarray[]= new String* [5];

Also, I'm not sure if it matters, but I usually use the Convert::ToString(x) function instead of String(x) to forces things to String format.

Hope this helps.