Collection property not working

  • Thread starter Thread starter Hessam
  • Start date Start date
H

Hessam

Hello,
I am designing a .net custom control in VS.net 7.1 and my control exposes an
array of strings which are supposed to be the items to show. To do this have
declared a private string[ ] variable and a public property which returns
it.
string[] options = new string[1];

public string[] Options

{

get

{

return options;

}

set

{

options = value;

}

}

It works fine in the disigner and I can add items to the list using the
VS.net string collection editor and see the changes in real-time. But when I
run the App, I recieve this error:

Cannot create an object of type 'System.String[]' from its string
representation 'String[] Array' for the 'Options' property.

Even with other types of collections (objects, etc.), I receive this error.
What should I do.
 
Hello,

It seems that either wrong code has been generated by the designer to
initialize the property (posting a generated piece of code would help a
lot), or, if your form is localizable, it might be that the collection
contents cannot be properly deserialized from the resource file.

You may try to employ "real" collections like NameValueCollection or custom
collections inherited from CollectionBase instead of plain arrays.
 
Back
Top