Visual C++ ListBox manipulation

Hello,

I'm a C++ coder, usually with puTTy (Unix). I'm building a program in Visual Studios, with C++ language.

I've built two clesses, one for 'item' and the other for a sorted linked list. Data from this list is meant to be added to a ListBox in my main form.

(Item contains two private variables: dataName, and visibleName)

In Form1.h, in my Form1() function along with my initilizer I have the function

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
UpdateListBox()
{
                  TableColumnsItemType item;
	         ColumnsSortedType list;
				 
		string str = "This is a sample";

		item.SetDataName(str);
		item.SetVisibleName();
		list.InsertItem(item);
		str = "This is also a sample";
		item.SetDataName(str);
		item.SetVisibleName();
		list.InsertItem(item);
		list.InsertItem(item);		 
		
		int length = list.LengthIs();
		int pos;
		for(pos = 0; pos < length; pos++)
		{
			list.GetNextItem(item);
			
			//add code to insert item into listbox
			this->listBox1->Items->Add(item.ReturnVisibleName());

		}
				
	}


Two issues: One, this->listBox1->Items->Add(item.ReturnVisibleName()); throws a conversion error
(C2664: cannot convert parameter 1 from std::string to System::Object) I'm not sure how to resolve this.

Second, I would prefer to update my ColumnsSortedType list in a seperate function, and have this function just read the list. But I fear that I would be passing "ColumnsSortedType list" as an argument all over the place. I'm assuming there isn't another way, but I thought I would check.

Thank you :)
Topic archived. No new replies allowed.