Windows Forms ListBox help!

From my understanding I can refer to specific items in a listBox via the index operators but it is not working. It builds and compiles but when the program reaches this part I get an error. My code is as follows:

this -> tbVol ->Text = Convert::ToString(this->lbData->Items[21]);

the error i receive is this:

An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in System.Windows.Forms.dll

Additional information: InvalidArgument=Value of '21' is not valid for 'index'.

please help me!
ArgumentOutOfRangeException is thrown when a method is invoked and at least one of the arguments passed to the method is not null and does not contain a valid value.

Possibly you are using only one argument where there should be two:
lbData [idc, index]
But I am not familiar with this topic so maybe I shouldn't be the one to reply.
Last edited on
Any other ideas?
Show some more relevant code and we can help.
does this help you any?

 array<Int32>^ gc = gcnew array<Int32>(9);
				 for(int i = 1; i<=9; i++)
					 gc[i-1] = i;
I figured it out thanks
Topic archived. No new replies allowed.