Hi all,
Although I tried several different ways, I wasn't able to succeed databinding a parameterized property. Can anyone help?
Thanks in advance,
AG
In a form with two text boxes on it, say in Load event, I write the following code:
1.Dim obj As New Person()
2.txtName.DataBindings.Add("Text", obj, "Name")
3.txtPhone.DataBindings.Add("Text", obj, "Phone(PhoneTypes.Home)")
Line 3 gives an error...
Public Enum PhoneTypes
Home = 0
Work = 1
Mobile = 2
End Enuö
Public Class Person
Private m_sName As String
Private m_colPhones as New HashTable()
Public Sub New()
m_sName = ""
m_colPhones.Add(PhoneTypes.Home, "")
m_colPhones.Add(PhoneTypes.Work, "")
m_colPhones.Add(PhoneTypes.Mobile, "")
End Sub
Public Property Name() As String
Get
Return m_sName
End Get
Set(Byval Value As String)
m_sName = Value
End Set
End Property
Public Property Phone(ByVal PhoneType As PhoneTypes) As String
Get
Return m_colPhones(PhoneType)
End Get
Set(ByVal Value As String)
If m_colPhones.ContainsKey(PhoneType) Then
m_colPhones(PhoneType) = Value
Else
m_colPhones.Add(PhoneType, Value)
End If
End Set
End Property
End Class