Asked By dgk
14-Sep-07 09:13 AM

On Thu, 13 Sep 2007 22:09:44 +0300, "Teemu Keiski"
Thanks much. I tried it (translated to VB since that's what I'm using)
and it worked. So I looked closer to see why my class, which was
roughly equivalent, didn't work. Oddly, it is something I did not
expect.
In VB, I've always used Public variables in classes rather than a
private variable and associated property declaration, unless I needed
greater control over the values coming in or going out. In fact, I
thought that the compiler just converted a public class variable into
a private variable and associated property clauses.
However, a generic collection of this class did not work with
databind:
Friend Class CaseChoice
Public ClientLastName As String
Public ClientFirstName As String
Public DocketInd As String
Public DOB As String
End Class
This class, with one public variable converted into a property, works
with Databind but only the one property shows on the grid:
Friend Class CaseChoice
Private _ClientLastName As String
Public ClientFirstName As String
Public DocketInd As String
Public DOB As String
Property ClientLastName() As String
Get
Return _ClientLastName
End Get
Set(ByVal value As String)
_ClientLastName = value
End Set
End Property
Public Sub New(ByVal InCLN As String)
_ClientLastName = InCLN
End Sub
End Class
This class works fine even though some properties are readonly and
others aren't:
Friend Class CaseChoice
Private _ClientLastName As String
Private _ClientFirstName As String
Private _DocketInd As String
Private _DOB As String
Property ClientLastName() As String
Get
Return _ClientLastName
End Get
Set(ByVal value As String)
_ClientLastName = value
End Set
End Property
Property ClientFirstName() As String
Get
Return _ClientFirstName
End Get
Set(ByVal value As String)
_ClientFirstName = value
End Set
End Property
ReadOnly Property DOB() As String
Get
Return _DOB
End Get
End Property
ReadOnly Property DocketInd() As String
Get
Return _DocketInd
End Get
End Property
Public Sub New(ByVal InCLN As String, ByVal InCFN As String, ByVal
InDI As String, ByVal InDOB As String)
_ClientLastName = InCLN
_ClientFirstName = InCFN
_DocketInd = InDI
_DOB = InDOB
End Sub
End Class
Very odd. I would thing that functionally a public variable would be
exactly the same as a property. Oh well, something new to look into. I
guess I'll have to look at the IL.