﻿<?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  » How to set parent of component to parent form at design time</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Thu, 07 May 2026 00:31:46 GMT</lastBuildDate><ttl>20</ttl><item><title>How to set parent of component to parent form at design time</title><link>http://forum.strataframe.net/FindPost24948.aspx</link><description>I'm trying to get a component to set a ParentForm property at design time and have it serialized.  I think you are doing something like this with the ParentContainer property when you implement the IInitOnFormLoad interface, but I'm not figuring it out.&lt;br&gt;
&lt;br&gt;
First, is this entirely handled via that property? It appears to be setting the value of the property, when in design mode, but what calls the property in design mode to begin with?&lt;br&gt;
&lt;br&gt;
Second, what causes the value to be serialized? In the setter, the component is added to the list of objects that need to be initialized. Is there something special that needs to happen to get it serialized?  I'm using C# if that makes difference or requires some extra step.</description><pubDate>Wed, 28 Oct 2009 19:30:29 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: How to set parent of component to parent form at design time</title><link>http://forum.strataframe.net/FindPost25046.aspx</link><description>Thanks Paul.  Between you and Trent I actually figured this out!</description><pubDate>Wed, 28 Oct 2009 19:30:29 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: How to set parent of component to parent form at design time</title><link>http://forum.strataframe.net/FindPost24961.aspx</link><description>Glad you got it.&lt;/P&gt;&lt;P&gt;To debug designer code you can go to the project properties of the project ,then debug and set the start action to stat external progam and point it to your visual studio instance devenv.exe. &lt;/P&gt;&lt;P&gt;Then&amp;nbsp;debug&amp;nbsp;will open a new instance of visual studio, you can then open up a test project and use the designer and debug&amp;nbsp;will hit breakpoints etc in your designer code (type converters custom properties etc).</description><pubDate>Wed, 21 Oct 2009 16:19:25 GMT</pubDate><dc:creator>Paul Chase</dc:creator></item><item><title>RE: How to set parent of component to parent form at design time</title><link>http://forum.strataframe.net/FindPost24960.aspx</link><description>I hadn't set that, but I didn't need to in any case (it is a simple object, an IParentContainer), so the default is fine.&lt;br&gt;
&lt;br&gt;
However, it did prompt me to work up a sample app that eventually allowed me figure it out. In translating the code from VB to C#, I didn't correctly handle this line:&lt;br&gt;
&lt;br&gt;
[codesnippet]'-- In ComboBox code, ParentContainer Get&lt;br&gt;
If (Not Array.IndexOf(CType(loDesigner.RootComponent, Object).GetType().GetInterfaces() _&lt;br&gt;
&amp;nbsp;&amp;nbsp;, GetType(MicroFour.StrataFrame.UI.Windows.Forms.IContainerControl)) &gt; -1) _&lt;br&gt;
&amp;nbsp;&amp;nbsp;AndAlso (loDesigner.RootComponent IsNot Me) Then&lt;br&gt;
[/codesnippet]&lt;br&gt;
&lt;br&gt;
The "Not Array.IndexOf(....) &gt; -1" really was making my brain hurt in C# after adding all the parentheses to handle casting and I didn't do that right. I changed it to:&lt;br&gt;
&lt;br&gt;
[codesnippet]//-- Check the type of the root component - changed from Not &gt; -1 to &lt; 0.&lt;br&gt;
if ((Array.IndexOf( ((object)(loDesigner.RootComponent)).GetType().GetInterfaces(), typeof( IContainerControl ) ) &lt; 0) &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;&amp; (loDesigner.RootComponent != this))&lt;br&gt;
[/codesnippet]&lt;br&gt;
&lt;br&gt;
Now it works correctly.  I'm still trying to figure out how to debug code that is written for the designer...&lt;br&gt;
&lt;br&gt;
Thanks for the help!</description><pubDate>Wed, 21 Oct 2009 15:44:24 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: How to set parent of component to parent form at design time</title><link>http://forum.strataframe.net/FindPost24955.aspx</link><description>Gregg,&lt;/P&gt;&lt;P&gt;Did you set the designerserialization attribute of the property? &lt;/P&gt;&lt;P&gt;[codesnippet]&lt;/P&gt;&lt;FONT size=2&gt;&lt;P&gt;&amp;lt;Category(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"Data Properties"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;), _&lt;/P&gt;&lt;P&gt;DesignerSerializationVisibility(DesignerSerializationVisibility.Content)&amp;gt; _&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Public&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Property&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; ReportParameters() &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; Generic.List(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Of&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; ReportParameter)&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;[/codesnippet]</description><pubDate>Wed, 21 Oct 2009 10:30:50 GMT</pubDate><dc:creator>Paul Chase</dc:creator></item></channel></rss>