Bryan,
Thanks for the response. Yes - I did set the Site property to the
same value as the outermost controls Site property. This had some
interesting effects. Firstly, it did not fix my problem, in design
time, the text boxes still appeared "alive". Secondly, it gave the
"DesignerSerialization" code fits. In the form.designer.cs, for the
form I had dropped my control into, it caused the "measurementWidget1"
variable to be defined multiple times all at once - the first time as
my control type, the next time as a panel, and three subsequent times
as text boxes. It also dumped all over the form's
InitializeComponents causing the "measurementWidget1" variable to be
newed multiple times (once as my widget, once as panel, and three
more times as a textbox). Needless to say, once I had finished my
design session, my Form1.cs class was a complete mess and could not
even compile.
So I figured that setting the Site property might be bad, so I figured
maybe I should cause the internal controls to be sited by creating
them using the IDesignerHost.CreateComponent method. So whenever I
needed to create any control within my control, (for instance, my
scrolling Panel) I did the following:
Panel scrollPanel = null;
IDesignerHost host = this.Container as IDesignerHost;
if (host != null)
{
scrollPanel = host.CreateComponent(typeof(Panel)) as Panel;
}
else
{
scrollPanel = new Panel();
}
// initialize Panel here
this.Controls.Add(scrollPanel);
I did something similar with all my TextBoxes as well. This had an
even stranger effect (if you can believe it). It caused all of the
internal bits of my control to be individually selectable withing the
designer. The were no longer "alive", but it now allowed me to clink
on an individual TextBox within my Control, and it even showed me the
correct properties for that TextBox. So. when I dropped my composite
widget on the form, I could individually select each TextBox on the
widget, and set any of its properties, or even move them around.
This, even though the TextBoxes are private to my control. And
whatever I did to my internal TextBoxes while designing my Form (for
instance set the back color purple) the changes would "stick" and
appear in run time. In this case, the DesignerSerialization code new
exactly what to do. This is very cool, actually, but not at all the
behavior I am looking for. I want my composite control to appear as a
single control, not as a "loose collection" of controls.
Anyway, getting the Site property right does not seem to be my
problem. Apparently, it is just a no-no to add additional controls to
your Controls list at Design time. Can anyone verify this? It seems
ike a pretty strange restriction.
On Apr 6, 10:25 pm, "Bryan Phillips"
<bphill...@nospam.spamcop.net.spammenot> wrote:
> What did you set the Site property to? I believe that you should set it
> to the same value as the outermost hosted control's Site property.
[quoted text clipped - 4 lines]
> Blog: http://bphillips76.spaces.live.com
> Web Site: http://www.composablesystems.net