Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Updating property values from a ComponentDesigner

0 views
Skip to first unread message

Lars-Håkan Jönsson

unread,
Apr 5, 2002, 12:34:32 PM4/5/02
to
I'm writing a ComponentDesigner for my control so that I
can load the controls property settings at design time.
The designer adds a DesignVerb to the control that
shows a file dialog to load different control settings.
We I use the control in design time to load the controls
property settings it loads and sets the propertys and
it works fine if you look in the property window BUT
the new property settings will not be preserved in the
code. So when I run my application i don't have my new
propertys values on the control. I guess that I have to
inform Visual Studio about me changeing the propertys
from code.... But how?

The LoadSine function only loads the
settings from file and sets all the properties.
My ComponentDesigner code:

Imports System.Windows.Forms
Imports System.ComponentModel
Imports System.ComponentModel.Design

Friend Class SineEngineDesigner
Inherits ComponentDesigner

Private mDesignVerbCol As New DesignerVerbCollection()

Public Sub New()
MyBase.New()

Dim clickVerb As New DesignerVerb("Load Sine", New
EventHandler(AddressOf VerbLoadSineClicked))
mDesignVerbCol.Add(clickVerb)
End Sub

Public Overrides ReadOnly Property Verbs() As
System.ComponentModel.Design.DesignerVerbCollection
Get
Return mDesignVerbCol
End Get
End Property

Private Sub VerbLoadSineClicked(ByVal sender As Object, ByVal e As
EventArgs)
Dim OpenSineDialog As New OpenFileDialog()

Try
With OpenSineDialog
.DefaultExt = "Sin"
.Filter = "SineMaker (*.Sin)|*.Sin"
.Title = "Load Sine"

If .ShowDialog = DialogResult.OK Then
'Loading new property settings for the control
CType(Component,
SineEngines.SineEngine).LoadSine(.FileName)

End If
End With
Catch err As Exception
MessageBox.Show(err.Message)
End Try

End Sub

End Class

/ Lars-Håkan

Shawn Burke [MSFT]

unread,
Apr 6, 2002, 3:37:12 PM4/6/02
to
You need to notify the designer which properties have changed as a result of
the verb being invoked. See the section on IComponentChangeService in:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/ht
ml/custdsgnrdotnet.asp

--

--

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2002 Microsoft Corporation. All rights
reserved.
"Lars-Håkan Jönsson" <lars-...@eqinox.com> wrote in message
news:OgfK4fM3BHA.1036@tkmsftngp04...

0 new messages