Problem with PropertyGrid and string based Collection

T

Terry

I created a collection derived from CollectionBase that is just made up of
strings, called "StringList". I have another object that has as a member
one of these StringList.

If I assign that object to a PropertyGrid, click on the collection editor
"..." and try to add a new string, I get an error message "Constructor on
type System.String not found.".

Any ideas what I'm missing? If it can't create a new object of one of the
built-in base types something is wrong.

Thanks,
Terry

Here's my "StringList" class for reference

using System;

using System.Collections;

namespace TestStringListAdd

{

/// <summary>

///

/// </summary>

public class StringList : CollectionBase

{

public StringList()

: base()

{

}

public void Add( String str )

{

this.List.Add( str );

}

public void Remove( String str )

{

this.List.Remove( str);

}

public string this[ int index ]

{

get

{

return (String)this.List[index];

}

}

}

}
 
T

Terry

I'll follow up on my own post with some additional information.

I discovered that "String" does not have a default constructor. Neither do
a number of other Framework classes, e.g. "IPEndPoint". So, if I were to
make a collection class of "IPEndPoint" derived from CollectionBase I run
into the same problem.

So, I guess the real question is how to handle these classes that don't have
default constructors so PropertyGrid can construct new instances of them?

Thanks!
Terry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top