473,326 Members | 2,148 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

changed Property of Public Control a Designtime on UserControl disapears!

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
4 2010
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Lecture Snoddddgrass | last post by:
Hi, When I create a UserControl-derived object, I often expose various public properties. One of the things that I hate about the WinForms designer is that if I decide to embed one of these...
0
by: Colin | last post by:
Hi there, I really need your help on this. I'm trying to learn to using the VS.2003 to create a User Control. In my aspx code has no problem to use the property "grossWaye" that has "register" in...
6
by: MP | last post by:
Hello I want to have a public property (and Brows able) in one control, I use this code: public System.Windows.Forms.Form recordForm get { return _recordForm;} set {_recordForm = value;}
7
by: Andrea Moro | last post by:
I'm writing my first windows control library. A simple textbox with some numeric facilities. Well, there is a strange thing that happen. I want to add a locked property. As many other property,...
6
by: Altman | last post by:
I would like to use an indexed property to access my private array of user controls. If I don't use an indexed property, the property will show up in my Properties Window during development. Is...
1
by: Will Gillen | last post by:
I know this has probably been asked before, but I can't seem to find a solid answer in any of the archives. First, before my question, please forgive my limited knowledge of the event lifecycle...
4
by: DraguVaso | last post by:
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...
1
by: bonk | last post by:
I have a very simple UserControl (derived from System.Windows.Forms.UserControl) that contains several ListViews. The UserControl exposes a single public property: public...
1
by: Don | last post by:
I'm getting the following exception displayed in the task list at design time for my project: "Code generation for property 'Controls' failed. Error was: 'Object reference not set to an...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.