﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » .NET Forums » General .NET Discussion  » Trouble with TypeConverter</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 01:52:35 GMT</lastBuildDate><ttl>20</ttl><item><title>Trouble with TypeConverter</title><link>http://forum.strataframe.net/FindPost17734.aspx</link><description>I have a control that includes a property that is an object that has two properties within it, a string and an integer.  I'd like this property to be an expandable property at design time in the property grid (like font, location, margins, ect are).  I've figured out that I need a TypeConverter for the object and have built that.  I figure out that I need to either override the GetPropertiesSupported and GetProperties methods or inherit from ExpandableObjectConverter (I've tried both) to get the parent object to expand into properties. &lt;br&gt;
&lt;br&gt;
The problem is that when that property is Nothing (null), I can't expand it.  Once I put in some appropriate text, then the plus sign shows up and the object's properties are expandable and shown.  It is very likely something stupid, but how do I get the property to be expandable when the property is Nothing (null)?&lt;br&gt;
&lt;br&gt;
Thanks!</description><pubDate>Mon, 18 Aug 2008 13:35:07 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Trouble with TypeConverter</title><link>http://forum.strataframe.net/FindPost18542.aspx</link><description>Cool...glad it worked out for you! :)</description><pubDate>Mon, 18 Aug 2008 13:35:07 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Trouble with TypeConverter</title><link>http://forum.strataframe.net/FindPost18512.aspx</link><description>I had a chance (finally) to look at this. I got it working quite easily using your changes as a guide! :w00t:&lt;br&gt;
&lt;br&gt;
I see now that I needed to always have an instance of the property object (the TopMostNode), rather than using Nothing.  Thanks again for the top notch support (above and beyond...).  :D</description><pubDate>Fri, 15 Aug 2008 15:43:17 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Trouble with TypeConverter</title><link>http://forum.strataframe.net/FindPost18023.aspx</link><description>No problem on the delay. Thanks I'll take a look at it!  This is much appreciated. You guys rock! :D</description><pubDate>Tue, 22 Jul 2008 18:09:50 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Trouble with TypeConverter</title><link>http://forum.strataframe.net/FindPost18004.aspx</link><description>OK....sorry for the REALLY long delay on this one.&amp;nbsp; But I have changed your code to work more in line with what I would do.&amp;nbsp; You will always want to have an instance of the object of some sort.&amp;nbsp; Instead of testing on Nothing, just test on a -1 for the ID or something along those lines.&amp;nbsp; You can also add a method on your TopMostNode item that tells if you it is in a default state to make this easier instead of writing the same thing over and over again (I did not write that method, but you get my point).</description><pubDate>Tue, 22 Jul 2008 09:39:39 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Trouble with TypeConverter</title><link>http://forum.strataframe.net/FindPost17857.aspx</link><description>Totally understand.  Hope training is going well (I'm sure it is). I wish I was there. :ermm:  I'm going to try for the next one.  Thanks for any time you can spare to take a quick look.</description><pubDate>Tue, 15 Jul 2008 11:33:23 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Trouble with TypeConverter</title><link>http://forum.strataframe.net/FindPost17855.aspx</link><description>Sorry, Greg.&amp;nbsp; We have just been swamped lately.&amp;nbsp; We are in class this week (and actually next as well).&amp;nbsp; So things should return to normal the last week of the month...but I will really try to look at this one night.</description><pubDate>Tue, 15 Jul 2008 10:38:23 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Trouble with TypeConverter</title><link>http://forum.strataframe.net/FindPost17836.aspx</link><description>I know y'all are busy, but if anyone gets chance, I've love some feedback/correction about what I'm doing wrong with this type converter.  :ermm:</description><pubDate>Mon, 14 Jul 2008 14:32:38 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Trouble with TypeConverter</title><link>http://forum.strataframe.net/FindPost17783.aspx</link><description>That did indeed help with serialization, but not much else.  I'm attaching a small project with the basics.  If you get a chance, could take a quick look and see if you can spot anything glaringly wrong?  I have a feeling I "that close"  :D</description><pubDate>Thu, 10 Jul 2008 18:40:02 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Trouble with TypeConverter</title><link>http://forum.strataframe.net/FindPost17781.aspx</link><description>Welcome to the world of frustrations :D&amp;nbsp; Yeah, creating design-time implementations can make you cuss!&lt;/P&gt;&lt;P&gt;One thing that you may be dealing with is the serialization as you mentioned.&amp;nbsp; If you have a collection, then you will want to assign the Content tag through the DesignerSerializationVisibility property.&amp;nbsp; Like this:&lt;/P&gt;&lt;P&gt;[codesnippet]Imports System.ComponentModel&lt;/P&gt;&lt;P&gt;Public Class MyTest&lt;/P&gt;&lt;P&gt;&lt;FONT style="BACKGROUND-COLOR: #dddd55"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DesignerSerializationVisibility(DesignerSerializationVisibility.Content)&amp;gt; _&lt;BR&gt;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Public Property MyProperty() As&amp;nbsp;MyCollection&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Get&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Get&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set(ByVal value As MyCollection)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Set&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Property&lt;/P&gt;&lt;P&gt;End Class&lt;BR&gt;[/codesnippet]&lt;/P&gt;&lt;P&gt;This might get you going in the right direction or at point you towards another attribute that would help.&amp;nbsp; The above tag can be used to just ensure that the serialization is visible as well.</description><pubDate>Thu, 10 Jul 2008 16:24:00 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Trouble with TypeConverter</title><link>http://forum.strataframe.net/FindPost17777.aspx</link><description>This is getting very frustrating.  I sort of got it working, but not in an acceptable manner. I the control, I added some code that would return a newly initialized object if in designmode and if the object was Nothing(null).  This solution would mean that I'd have to remember to add that code any place I use this object...not good.&lt;br&gt;
&lt;br&gt;
I'm starting to think this might have something to do with serialization.  What do I need to do to make this property serialize correctly?  Currently it is doing this...which isn't really working:&lt;br&gt;
&lt;br&gt;
[codesnippet]    Me.dtvOutline.TopMostNode = CType(resources.GetObject("dtvOutline.TopMostNode"), FOXSystems.RAMS.UI.Forms.Controls.TopMostTreeNode)[/codesnippet]&lt;br&gt;
&lt;br&gt;
What I'd expect is something more alone these lines:&lt;br&gt;
[codesnippet]  Me.dtvOutline.TopMostNode.TopMostText = "(unassigned)"&lt;br&gt;
  Me.dtvOutline.TopMostNode.TopMostID = 0[/codesnippet] &lt;br&gt;
&lt;br&gt;
The TopMostNode is of type TopMostTreeNode, which has been marked with the TypeConverter, Serializable and Browsable(True) attributes.  What am I missing?</description><pubDate>Thu, 10 Jul 2008 15:26:07 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Trouble with TypeConverter</title><link>http://forum.strataframe.net/FindPost17745.aspx</link><description>You can take the Null value into account within the TypeConverter and "pretend" it has a value.&amp;nbsp; Another option is to initialize the value to a blank or empty value, which is generally what is done most of the time.&lt;/P&gt;&lt;P&gt;The first place I would look would be the CanConvertFrom method and see if it is getting fired when Nothing (null) is being passed over...I would expect that it does.&amp;nbsp; If so, then you can take matters into you own hands and supply a value which should allow the designer to expand.</description><pubDate>Thu, 10 Jul 2008 08:27:36 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item></channel></rss>