S
Simon Verona
sleep?? whats that????
Simon
Dont forget to sleep J
All the best and "play a lot" with the 'IComponentChangeService'. It's powerfull to use (but a hell to Debug...Since it's IDE)
Michael
Thanks Michael,
I think I'll sit down when I have a quiet few hours and play with this... I think I have to get to grip with the concepts that you have outlined.
I'll let you know how I get on!
Regards
Simon
Hey Simon,
Does this fully answer your questions, because I came to the conclusion I didn't point out how to actually set your binding.
On the other hand, I was thinking if your DataObjects are on the Form or ComponentTray, you could set the Binding in Design-time through the Property-Window. Sure your DataObjects must all inherit from the same BaseClass, so you could do something like:
Dim _DataSource As YourBaseClass
<EditorBrowsable(EditorBrowsableState.Always), _
Category("Data"), _
Browsable(True), _
Bindable(True), _
Description("The DataObject to bind the TextBox to."), _
TypeConverter("System.Windows.Forms.Design.DataSourceConverter, System.Design"), _
RefreshProperties(RefreshProperties.All)> _
Public Overloads Property DataSource() As Object
Get
Return _DataSource
End Get
Set(ByVal Value As Object)
_DataSource = Value
End Set
End Property
Should you use this approach, then you have to fine-tune this property, because it's for Complex-DataBinding and as you know, the TextBox-Class has Simple DataBinding. Doing this you would get a dropdown-list with all possible DataObjects your TextBox can bind to.
Anyway: should you furthermore want to make use of the 'IComponentChangeService' then you would defently need Reflection to Get/Set some values of Components/Controls which you don't know of in Design-Time. Something like:
Private Sub OnComponentRename(ByVal sender As Object, ByVal ce As ComponentRenameEventArgs)
If IsNothing(ce) Or IsNothing(ce.Component) Then Exit Sub
Dim ot As Object = ce.Component
Dim s As String = ot.GetType.ToString
Dim p As PropertyInfo
' Set a Boolean-Property
p = ot.GetType.GetProperty("MyDesiredPropertyName")
p.SetValue(ot, False, Nothing)
' Set a String-Property
p = ot.GetType.GetProperty("MyOtherDesiredPropertyName")
p.SetValue(ot, ce.NewName, Nothing)
' Continue other logic
.........................................................
.........................................................
End Sub
Also keep in mind with the 'IComponentChangeService' that you address the right INSTANCE, because if you have two or more controls of the same type on a form, then it will loop through all those controls (even if this service is called from within a single control)!!
I wish you the best, and let me know if you could manage your goal.
Kind regards,
Michael
Michael,
Thanks very much for digging out the code.
Regards
Simon
Simon
Dont forget to sleep J
All the best and "play a lot" with the 'IComponentChangeService'. It's powerfull to use (but a hell to Debug...Since it's IDE)
Michael
Thanks Michael,
I think I'll sit down when I have a quiet few hours and play with this... I think I have to get to grip with the concepts that you have outlined.
I'll let you know how I get on!
Regards
Simon
Hey Simon,
Does this fully answer your questions, because I came to the conclusion I didn't point out how to actually set your binding.
On the other hand, I was thinking if your DataObjects are on the Form or ComponentTray, you could set the Binding in Design-time through the Property-Window. Sure your DataObjects must all inherit from the same BaseClass, so you could do something like:
Dim _DataSource As YourBaseClass
<EditorBrowsable(EditorBrowsableState.Always), _
Category("Data"), _
Browsable(True), _
Bindable(True), _
Description("The DataObject to bind the TextBox to."), _
TypeConverter("System.Windows.Forms.Design.DataSourceConverter, System.Design"), _
RefreshProperties(RefreshProperties.All)> _
Public Overloads Property DataSource() As Object
Get
Return _DataSource
End Get
Set(ByVal Value As Object)
_DataSource = Value
End Set
End Property
Should you use this approach, then you have to fine-tune this property, because it's for Complex-DataBinding and as you know, the TextBox-Class has Simple DataBinding. Doing this you would get a dropdown-list with all possible DataObjects your TextBox can bind to.
Anyway: should you furthermore want to make use of the 'IComponentChangeService' then you would defently need Reflection to Get/Set some values of Components/Controls which you don't know of in Design-Time. Something like:
Private Sub OnComponentRename(ByVal sender As Object, ByVal ce As ComponentRenameEventArgs)
If IsNothing(ce) Or IsNothing(ce.Component) Then Exit Sub
Dim ot As Object = ce.Component
Dim s As String = ot.GetType.ToString
Dim p As PropertyInfo
' Set a Boolean-Property
p = ot.GetType.GetProperty("MyDesiredPropertyName")
p.SetValue(ot, False, Nothing)
' Set a String-Property
p = ot.GetType.GetProperty("MyOtherDesiredPropertyName")
p.SetValue(ot, ce.NewName, Nothing)
' Continue other logic
.........................................................
.........................................................
End Sub
Also keep in mind with the 'IComponentChangeService' that you address the right INSTANCE, because if you have two or more controls of the same type on a form, then it will loop through all those controls (even if this service is called from within a single control)!!
I wish you the best, and let me know if you could manage your goal.
Kind regards,
Michael
Michael,
Thanks very much for digging out the code.
Regards
Simon