Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Setting properties on hosted toolstrip control at design time

Reply
 
Old 07-30-2009   #1 (permalink)
Mike


 
 

Setting properties on hosted toolstrip control at design time

I created my own toolstrip control using ToolStripControlHost. When I
add this to a toolstrip, I want to adjust the properties of the hosted
control in the designer but they always get reset when I compile. Can
anyone tell me how to fix this? This should be similar to accessing
the panels in a SplitContainer control so I think it is possible.

Here is some *sample* code to illustrate the problem.

[ToolStripItemDesignerAvailability
(ToolStripItemDesignerAvailability.ToolStrip |
ToolStripItemDesignerAvailability.StatusStrip)]
public class ToolStripHostExample : ToolStripControlHost
{
public TextBox MyControl
{
get { return (TextBox)Control; }
}

public ToolStripHostExample() : base(new TextBox())
{
}
}

Add it to a toolstrip and try to set the MyControl.ReadOnly attribute
to true in the designer. When you compile, the property will be reset
to false.

My System SpecsSystem Spec
Old 07-31-2009   #2 (permalink)
Mike


 
 

Re: Setting properties on hosted toolstrip control at design time

For anyone else struggling with a similar problem, I found the
solution by taking a closer look at the panels in theSplitContainer
control.

Adding the DesignerSerializationVisibility attribute to the MyControl
property in my sample code solves the problem. Here is the fixed
sample code...

[ToolStripItemDesignerAvailability
(ToolStripItemDesignerAvailability.ToolStrip |
ToolStripItemDesignerAvailability.StatusStrip)]
public class ToolStripHostExample : ToolStripControlHost
{
[DesignerSerializationVisibility
(DesignerSerializationVisibility.Content)]
public TextBox MyControl
{
get { return (TextBox)Control; }
}

public ToolStripHostExample() : base(new TextBox())
{
}
}


On Jul 30, 4:48*pm, Mike <MLM...@xxxxxx> wrote:
Quote:

> I created my own toolstrip control using ToolStripControlHost. When I
> add this to a toolstrip, I want to adjust the properties of the hosted
> control in the designer but they always get reset when I compile. Can
> anyone tell me how to fix this? This should be similar to accessing
> the panels in a SplitContainer control so I think it is possible.
>
> Here is some *sample* code to illustrate the problem.
>
> [ToolStripItemDesignerAvailability
> (ToolStripItemDesignerAvailability.ToolStrip |
> ToolStripItemDesignerAvailability.StatusStrip)]
> public class ToolStripHostExample : ToolStripControlHost
> {
> * public TextBox MyControl
> * {
> * * get { return (TextBox)Control; }
> * }
>
> * public ToolStripHostExample() : base(new TextBox())
> * {
> * }
>
> }
>
> Add it to a toolstrip and try to set the MyControl.ReadOnly attribute
> to true in the designer. When you compile, the property will be reset
> to false.
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Can't read appSettings of IE hosted control when under SSL .NET General
Security questions around browser hosted control interaction. .NET General
Re: Problem running .NET user control hosted on Windows Vista / IE 7 Vista security
Problem running .NET user control hosted on Windows Vista / IE 7 Vista security


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46