TypeConverter and Generic Lists

G

Guest

Hi I am having a bit of difficulty with TypeConverters and Generic Lists and
I was hoping that I could get a bit of advice.

I have a type converter that is used to create the constructor code for my
component. (It is an XNA a Game Component, but I don't think that that has
anything to do with the problem because it appears on a Winform) inside
another component.

For instance I have the following:

public class A{
private string s;
public string SProp
{
get{ s = value;}
set {return s;}
}

public A()
{
s = "";
}
public A(string inS)
{
s = inS;
}
}

By itself, when class A is an object on a form (or in my XNA Component) the
TypeConverter code works fine, the property grid on the desinger is fine, if
I debug the ConvertTo on the type converter I see that the variable s is all
set up okay on the object.

However if on my form, I have a List<A>, the type converter works to an
extent, as in it will add code to the perform the List.Add(new A("")),
however the constructor with the parameter is not being called, instead the
parameterless constructor is being called.

Obviously, if the input to ConvertTo on the type converter is not set up,
then my type converter won't work or display the values the user has put in.
This only occurs when my object is in a Generic List.

Any Ideas,
Paul Kinlan

My environment is VS2005 C# and also VS2005 C# express.
 

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