Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I have a question regarding a design-time problem.
In VB.net 2010 I have a custom control who's properties are being set by another custom control through a UITypeEditor (through code).
The changes are made, however the IDE does not persist these settings. Meaning that there does not appear a star in the form tab to indicate that the form has been marked dirty and hence is saved when I store the project.
Only when I manually make other changes to the form the star appears (dirty form marker), and my property settings are persisted.

Does anyone know how to solve this problem?
Is there a way to set the dirty form marker at design time through code ?
Is there a way to notify the IDE that changes have been made to a certain control, in order to mark it's container form as dirty?

Thanks in advance.
Posted

1 solution

You're probably missing the
<DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)>
attribute on your controls properties that you want the designer to write code for.

Add this attribute to every property that you want design-time value support for and the designer will generate code for it.
 
Share this answer
 
v2
Comments
Wietze Bron 19-Feb-12 12:44pm    
Thanks for you reply Dave.
Unfortunately it does not work.
Dave Kreskowiak 19-Feb-12 14:33pm    
Seriously, that's all it takes. For example:

<Bindable(True), DefaultValue(True), Category("Behavior"), _
Description("Gets or sets whether the control will stay within its parent container's visible bounds."), _
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)> _
Public Property StayWithinParentBounds() As Boolean
Get
Return m_StayWithinParent
End Get

Set(ByVal value As Boolean)
If value <> m_StayWithinParent Then
m_StayWithinParent = value
MoveControlWithinBounds()
Me.OnStayWithinParentBoundsChanged(EventArgs.Empty)
End If
End Set
End Property
Wietze Bron 20-Feb-12 12:11pm    
Are you doing something special in the OnStayWithinParentBoundsChanged ?
I did the same you did. Here it doesn't work.
Maybe it's the way I work. I am changing the (not browsable) property out of another form through a UITypeEditor.
Dave Kreskowiak 20-Feb-12 14:47pm    
I'm not doing anything special anywhere. The code you see is what I'm using. You don't even need the Me.OnStayWithinParentBounds method. It has no bearing on the ability of the designer to write code for setting this value at all.
Dave Kreskowiak 20-Feb-12 14:54pm    
I am changing the (not browsable) property out of another form through a UITypeEditor.

It seems you're the one doing something special. I can't remember but I don't believe a Browsable(False) property is eligible to have its value saved in the Designer generated code.

It's simple enough to test. Just leave leave the Browsable attribute as True (the default) and try it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900