Problem with List 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:   Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.


This content originally appeared on Modern Web Development with Chrome and was authored by Paul Kinlan

<p>I am having a bit of difficulty with TypeConverters and Generic Lists and I was hoping that I could get a bit of advice. </p> <p>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. </p> <p>For instance I have the following: </p> <p> </p> <div class="wlWriterSmartContent" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px;"> <p /> <div> Code highlighting produced by Actipro CodeHighlighter (freeware)<a href="http://www.CodeHighlighter.com/">http://www.CodeHighlighter.com/</a><p />--><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">class</span><span style="color: #000000;"> A{ </span><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">string</span><span style="color: #000000;"> s; </span><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">string</span><span style="color: #000000;"> SProp { </span><span style="color: #0000FF;">get</span><span style="color: #000000;">{ s </span><span style="color: #000000;">=</span><span style="color: #000000;"> value;} </span><span style="color: #0000FF;">set</span><span style="color: #000000;"> {</span><span style="color: #0000FF;">return</span><span style="color: #000000;"> s;} }<p /> </span><span style="color: #0000FF;">public</span><span style="color: #000000;"> A() { s </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">""</span><span style="color: #000000;">; } </span><span style="color: #0000FF;">public</span><span style="color: #000000;"> A(</span><span style="color: #0000FF;">string</span><span style="color: #000000;"> inS) { s </span><span style="color: #000000;">=</span><span style="color: #000000;"> inS; }}</span> </div> </div><p>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. </p><p>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.  </p><p>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.</p><p>Can anyone suggest anything to look at?</p><p>tags: <a href="http://www.kinlan.co.uk/tag/question" rel="tag">question</a>, <a href="http://www.kinlan.co.uk/tag/c#" rel="tag">c#</a>, <a href="http://www.kinlan.co.uk/tag/.net" rel="tag">.net</a>, <a href="http://www.kinlan.co.uk/tag/generics" rel="tag">generics</a>, <a href="http://www.kinlan.co.uk/tag/typeconverter" rel="tag">typeconverter</a></p>


This content originally appeared on Modern Web Development with Chrome and was authored by Paul Kinlan


Print Share Comment Cite Upload Translate Updates
APA

Paul Kinlan | Sciencx (2006-09-23T00:00:00+00:00) Problem with List and TypeConverter. Retrieved from https://www.scien.cx/2006/09/23/problem-with-list-and-typeconverter/

MLA
" » Problem with List and TypeConverter." Paul Kinlan | Sciencx - Saturday September 23, 2006, https://www.scien.cx/2006/09/23/problem-with-list-and-typeconverter/
HARVARD
Paul Kinlan | Sciencx Saturday September 23, 2006 » Problem with List and TypeConverter., viewed ,<https://www.scien.cx/2006/09/23/problem-with-list-and-typeconverter/>
VANCOUVER
Paul Kinlan | Sciencx - » Problem with List and TypeConverter. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2006/09/23/problem-with-list-and-typeconverter/
CHICAGO
" » Problem with List and TypeConverter." Paul Kinlan | Sciencx - Accessed . https://www.scien.cx/2006/09/23/problem-with-list-and-typeconverter/
IEEE
" » Problem with List and TypeConverter." Paul Kinlan | Sciencx [Online]. Available: https://www.scien.cx/2006/09/23/problem-with-list-and-typeconverter/. [Accessed: ]
rf:citation
» Problem with List and TypeConverter | Paul Kinlan | Sciencx | https://www.scien.cx/2006/09/23/problem-with-list-and-typeconverter/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.