. Topicala Page Index Token

A Journal about the experiences I have developing little applications in C#, Perl, Html and Javascript and talking about things new things that I use. Always Geeky; Always Nerdy; Always poor Grammer!

I am a Software Analyst Developer working in Southport, England but living in Liverpool. I develop mainly in C# and ASP.Net. I have been developing comercial software for several years now. I maintain this site (hosted at SwitchMedia UK) as a way of exploring new technologies (such as AJAX) and just generally talking about techie geek issues. This site is developed through a host of Perl scripts and a liberal use of Javascript. I enjoy experimenting with new technologies and anything that I make I host here.

Quick Search

Web www.kinlan.co.uk

Saturday, September 23, 2006

Problem with List<T> and TypeConverter

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.


Can anyone suggest anything to look at?


tags: , , , ,

Comments: [Add New]

I have worked out the problem

I will post an update later.

By Paul Kinlan, at Friday, September 29, 2006 9:24:00 AM

Your code in the Get{..} and Set{..} need to be swapped around.

By Anonymous, at Tuesday, July 17, 2007 2:06:00 AM