Есть компонент с некоторыми свойствами. Необходимо редактировать их в собственном дизайнере.
В DesignTime все редактируется, но в RunTime проподает, т. э . форма(контейнер) где находится компонент
эти данные не сохраняет...
Плиз, подскажите, как исправить?
Пример кода (сокращенно):
- Код: Выделить всё
<Designer(GetType(MyComponentDesigner))> _
Public Class MyComponent
Inherits Component
Private _a As Integer
Private _b As Integer
Public Property A() As Integer
Get
Return _a
End Get
Set(ByVal value As Integer)
_a = value
End Set
End Property
Public Property B() As Integer
Get
Return _b
End Get
Set(ByVal value As Integer)
_b = value
End Set
End Property
End Class
Public Class MyComponentDesigner
Inherits System.ComponentModel.Design.ComponentDesigner
Public Sub New()
End Sub
Public Overrides Sub Initialize(ByVal component As System.ComponentModel.IComponent)
MyBase.Initialize(component)
End Sub
Public Overrides ReadOnly Property Verbs() As System.ComponentModel.Design.DesignerVerbCollection
Get
Return New DesignerVerbCollection(New DesignerVerb() _
{New DesignerVerb("Editor", New EventHandler(AddressOf Me.onVerb))})
End Get
End Property
Private Sub onVerb(ByVal sender As Object, ByVal e As EventArgs)
Dim editor As New MyComponentEditor(Me.Component)
editor.ShowDialog()
End Sub
End Class
Public Class MyComponentEditor ' форма
Private _mc As MyComponent
Sub New(ByVal mc As MyComponent)
InitializeComponent()
_mc = mc
End Sub
Private Sub MyComponentEditor_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.NumericUpDown1.Value = _mc.A
Me.NumericUpDown1.Value = _mc.B
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
_mc.A = Me.NumericUpDown1.Value
_mc.B = Me.NumericUpDown2.Value
Me.Close()
End Sub
End Class