Problem with List and TypeConverter

Paul Kinlan

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:

 


Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->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.


Can anyone suggest anything to look at?


tags: , , , ,

Paul Kinlan

Trying to make the web and developers better.

RSS Github Medium