SetProperty() problems with SmartDate - winForms Databinding / BusinessBase

SetProperty() problems with SmartDate - winForms Databinding / BusinessBase

Old forum URL: forums.lhotka.net/forums/t/7793.aspx


Reto posted on Thursday, October 15, 2009

Dear Rocky

It seems that SetProperty does not work correct with SmartDate.

1) any (default) values set by the databinding are not reflectet on the control
2) BusinessRules (StringRequired etc.) do not have the new value set by the SetProperty.

I have in my BusinessBase class the following code:

Private mSomeDate As New SmartDate(False)
...
Private Shared SomeDateProperty As PropertyInfo(Of String) = RegisterProperty(New PropertyInfo(Of String)("SomeDate"))
Public Property SomeDate() As String
Get
Return GetProperty(Of String)(SomeDateProperty, mSomeDate.Text)
End Get
Set(ByVal Value As String)
SetProperty(Of String)(SomeDateProperty, mSomeDate.Text, Value)
End Set
End Property

regards reto

RockfordLhotka replied on Thursday, October 15, 2009

You need to use SetPropertyConvert() and GetPropertyConvert() when the type of the property does not match the type of the backing value.

In your example the type of the property is string and the type of the backing value is datetime, so you need to convert between the two types.

Copyright (c) Marimer LLC