changed Property of Public Control a Designtime on UserControl disapears!

D

DraguVaso

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
 
T

Tim Wilson

You'll need the DesignerSerializationVisibility attribute. The code below
shows how this can be used.

private ToolBar mainToolBarValue = new ToolBar();

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

DraguVaso

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.DesignerSerializationVisibility(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 said:
You'll need the DesignerSerializationVisibility attribute. The code below
shows how this can be used.

private ToolBar mainToolBarValue = new ToolBar();

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

--
Tim Wilson
.Net Compact Framework MVP

DraguVaso said:
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
 
T

Tim Wilson

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 said:
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.DesignerSerializationVisibility(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 said:
You'll need the DesignerSerializationVisibility attribute. The code below
shows how this can be used.

private ToolBar mainToolBarValue = new ToolBar();

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

--
Tim Wilson
.Net Compact Framework MVP

DraguVaso said:
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
 
D

DraguVaso

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 said:
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 said:
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.DesignerSerializationVisibility(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
You'll need the DesignerSerializationVisibility attribute. The code below
shows how this can be used.

private ToolBar mainToolBarValue = new ToolBar();

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

--
Tim Wilson
.Net Compact Framework MVP

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top