By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,934 Members | 1,449 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,934 IT Pros & Developers. It's quick & easy.

changed Property of Public Control a Designtime on UserControl disapears!

P: n/a
Hi,

I'm having some weird behaviour, and I can't find any solution to this.

I made a UserControl (uclCommands) which contains a Toolbar (ToolBar1) with
Modifiers = Public.
I put this usercontrol on my form and call it Ucl1. In the Property Window
in the Windows Forms Designer I change Ucl1.ToolBar1.ButtonSize to a bigger
value.

Everything goes fine: The buttons get the larger size. but after I compile,
the ButtonSize gets again the original size.....

Does anybody knows why this happens, and what I can do about it? I really
need this because my Usercontrol must have different sizes in my
application.

I tested this with Visual Studio 2005 beta 2 and VS 2003: Both the same
behaviour...

Any help or hints would be really appreciated!

Thanks a lot in advance,

Pieter
Sep 15 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
You'll need the DesignerSerializationVisibility attribute. The code below
shows how this can be used.

private ToolBar mainToolBarValue = new ToolBar();

[DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content)]
public ToolBar MainToolBar
{
get
{
return mainToolBarValue;
}
}

--
Tim Wilson
..Net Compact Framework MVP

"DraguVaso" <pi**********@hotmail.com> wrote in message
news:uP*************@TK2MSFTNGP12.phx.gbl...
Hi,

I'm having some weird behaviour, and I can't find any solution to this.

I made a UserControl (uclCommands) which contains a Toolbar (ToolBar1) with Modifiers = Public.
I put this usercontrol on my form and call it Ucl1. In the Property Window
in the Windows Forms Designer I change Ucl1.ToolBar1.ButtonSize to a bigger value.

Everything goes fine: The buttons get the larger size. but after I compile, the ButtonSize gets again the original size.....

Does anybody knows why this happens, and what I can do about it? I really
need this because my Usercontrol must have different sizes in my
application.

I tested this with Visual Studio 2005 beta 2 and VS 2003: Both the same
behaviour...

Any help or hints would be really appreciated!

Thanks a lot in advance,

Pieter

Sep 15 '05 #2

P: n/a
hi,

This seems to point me into the right direction, although I have the
impression that it's only for custom porperty's. not for existing proeprty's
of a standard control. I should kind have the same thing for all the
property's of all the control's on my usercontrol. I should be able to
change all those property's, andn ot to loose them after compiling.

I googled for it but didn't find smething that suits me :-/

I tried something like this but it didn't work:
Option Explicit On

<System.ComponentModel.DesignerSerializationVisibi lity(System.ComponentModel
..DesignerSerializationVisibility.Content)> _

Public Class ucl

Inherits System.Windows.Forms.UserControl

#Region " Windows Form Designer generated code "

Public Sub New()

MyBase.New()

"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
You'll need the DesignerSerializationVisibility attribute. The code below
shows how this can be used.

private ToolBar mainToolBarValue = new ToolBar();

[DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content)]
public ToolBar MainToolBar
{
get
{
return mainToolBarValue;
}
}

--
Tim Wilson
.Net Compact Framework MVP

"DraguVaso" <pi**********@hotmail.com> wrote in message
news:uP*************@TK2MSFTNGP12.phx.gbl...
Hi,

I'm having some weird behaviour, and I can't find any solution to this.

I made a UserControl (uclCommands) which contains a Toolbar (ToolBar1)

with
Modifiers = Public.
I put this usercontrol on my form and call it Ucl1. In the Property Window in the Windows Forms Designer I change Ucl1.ToolBar1.ButtonSize to a

bigger
value.

Everything goes fine: The buttons get the larger size. but after I

compile,
the ButtonSize gets again the original size.....

Does anybody knows why this happens, and what I can do about it? I really need this because my Usercontrol must have different sizes in my
application.

I tested this with Visual Studio 2005 beta 2 and VS 2003: Both the same
behaviour...

Any help or hints would be really appreciated!

Thanks a lot in advance,

Pieter


Sep 16 '05 #3

P: n/a
You shouldn't need to apply the "DesignerSerializationVisibility" attribute
to all the properties in your custom control. This attribute is used in
special instances when values within the property value should be stored, as
opposed to the property value itself. And the usage of this attribute
prohibits it from being used at the class level. You can "add" attributes to
an existing property by overriding the base property or hiding the base
property within your definition. For example, the code below overrides the
base property "BackColor" and hides it from being displayed in the
properties window by using the "Browsable" attribute.

<Browsable(False)> _
Public Overrides Property BackColor() As System.Drawing.Color
Get
Return MyBase.BackColor
End Get
Set(ByVal Value As System.Drawing.Color)
MyBase.BackColor = Value
End Set
End Property

--
Tim Wilson
..Net Compact Framework MVP

"DraguVaso" <pi**********@hotmail.com> wrote in message
news:On**************@TK2MSFTNGP15.phx.gbl...
hi,

This seems to point me into the right direction, although I have the
impression that it's only for custom porperty's. not for existing proeprty's of a standard control. I should kind have the same thing for all the
property's of all the control's on my usercontrol. I should be able to
change all those property's, andn ot to loose them after compiling.

I googled for it but didn't find smething that suits me :-/

I tried something like this but it didn't work:
Option Explicit On

<System.ComponentModel.DesignerSerializationVisibi lity(System.ComponentModel .DesignerSerializationVisibility.Content)> _

Public Class ucl

Inherits System.Windows.Forms.UserControl

#Region " Windows Form Designer generated code "

Public Sub New()

MyBase.New()

"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
You'll need the DesignerSerializationVisibility attribute. The code below
shows how this can be used.

private ToolBar mainToolBarValue = new ToolBar();

[DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content)] public ToolBar MainToolBar
{
get
{
return mainToolBarValue;
}
}

--
Tim Wilson
.Net Compact Framework MVP

"DraguVaso" <pi**********@hotmail.com> wrote in message
news:uP*************@TK2MSFTNGP12.phx.gbl...
Hi,

I'm having some weird behaviour, and I can't find any solution to this.
I made a UserControl (uclCommands) which contains a Toolbar (ToolBar1)

with
Modifiers = Public.
I put this usercontrol on my form and call it Ucl1. In the Property

Window in the Windows Forms Designer I change Ucl1.ToolBar1.ButtonSize to a

bigger
value.

Everything goes fine: The buttons get the larger size. but after I

compile,
the ButtonSize gets again the original size.....

Does anybody knows why this happens, and what I can do about it? I really need this because my Usercontrol must have different sizes in my
application.

I tested this with Visual Studio 2005 beta 2 and VS 2003: Both the same behaviour...

Any help or hints would be really appreciated!

Thanks a lot in advance,

Pieter



Sep 16 '05 #4

P: n/a
Ok! Thanks for then ice explanation.
Unfortunately I have to make a 'custom' toolbar for it that inherits the
base-toolbar and overrides it methods. thats less nice aboutthis solution :)
but thansk anyways!
"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in message
news:eC**************@TK2MSFTNGP12.phx.gbl...
You shouldn't need to apply the "DesignerSerializationVisibility" attribute to all the properties in your custom control. This attribute is used in
special instances when values within the property value should be stored, as opposed to the property value itself. And the usage of this attribute
prohibits it from being used at the class level. You can "add" attributes to an existing property by overriding the base property or hiding the base
property within your definition. For example, the code below overrides the
base property "BackColor" and hides it from being displayed in the
properties window by using the "Browsable" attribute.

<Browsable(False)> _
Public Overrides Property BackColor() As System.Drawing.Color
Get
Return MyBase.BackColor
End Get
Set(ByVal Value As System.Drawing.Color)
MyBase.BackColor = Value
End Set
End Property

--
Tim Wilson
.Net Compact Framework MVP

"DraguVaso" <pi**********@hotmail.com> wrote in message
news:On**************@TK2MSFTNGP15.phx.gbl...
hi,

This seems to point me into the right direction, although I have the
impression that it's only for custom porperty's. not for existing

proeprty's
of a standard control. I should kind have the same thing for all the
property's of all the control's on my usercontrol. I should be able to
change all those property's, andn ot to loose them after compiling.

I googled for it but didn't find smething that suits me :-/

I tried something like this but it didn't work:
Option Explicit On

<System.ComponentModel.DesignerSerializationVisibi lity(System.ComponentModel
.DesignerSerializationVisibility.Content)> _

Public Class ucl

Inherits System.Windows.Forms.UserControl

#Region " Windows Form Designer generated code "

Public Sub New()

MyBase.New()

"Tim Wilson" <TIM(UNDERSCORE)WILSON(AT)ROGERS(PERIOD)COM> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
You'll need the DesignerSerializationVisibility attribute. The code

below shows how this can be used.

private ToolBar mainToolBarValue = new ToolBar();

[DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content)] public ToolBar MainToolBar
{
get
{
return mainToolBarValue;
}
}

--
Tim Wilson
.Net Compact Framework MVP

"DraguVaso" <pi**********@hotmail.com> wrote in message
news:uP*************@TK2MSFTNGP12.phx.gbl...
> Hi,
>
> I'm having some weird behaviour, and I can't find any solution to this. >
> I made a UserControl (uclCommands) which contains a Toolbar (ToolBar1) with
> Modifiers = Public.
> I put this usercontrol on my form and call it Ucl1. In the Property

Window
> in the Windows Forms Designer I change Ucl1.ToolBar1.ButtonSize to a
bigger
> value.
>
> Everything goes fine: The buttons get the larger size. but after I
compile,
> the ButtonSize gets again the original size.....
>
> Does anybody knows why this happens, and what I can do about it? I

really
> need this because my Usercontrol must have different sizes in my
> application.
>
> I tested this with Visual Studio 2005 beta 2 and VS 2003: Both the same > behaviour...
>
> Any help or hints would be really appreciated!
>
> Thanks a lot in advance,
>
> Pieter
>
>



Sep 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.