我编写了一个类,并希望它的属性显示在DataGridView控件中。但是,只有一些属性可用于绑定到列。如何使所有公共属性可用于绑定到列?以下是我的课程,IndividualServices属性不会出现在设计师中,而其他属性则是。
Public Class Patient
Private _name As String
Private _id As String
Private _services As New List(Of Service)
Property Name As String
Get
Return _name
End Get
Set(value As String)
_name = value
End Set
End Property
Property ID As String
Get
Return _id
End Get
Set(value As String)
_id = value
End Set
End Property
Public ReadOnly Property Services As List(Of Service)
Get
Return _services
End Get
End Property
ReadOnly Property TotalServices As Integer
Get
Dim i As Integer = 0
For Each s As Service In _services
i = i + s.Count
Next s
Return i
End Get
End Property
ReadOnly Property IndividualServices As Integer
Get
Return _services.Count
End Get
End Property
Public Sub Add(sName As String, sCode As String)
Dim bool As Boolean = False
If _services.Count = 0 Then GoTo firstThrough
For Each s As Service In _services
If s.Name = sName Then
s.Add(1)
bool = True
Exit For
End If
Next
If Not bool Then
firstThrough:
Dim newSer As New Service
newSer.Name = sName
newSer.Code = sCode
newSer.Count = 1
_services.Add(newSer)
End If
End Sub
End Class
答案 0 :(得分:0)
事实证明,清洁和重建解决方案解决了我的问题!将来会更频繁地采取这些步骤。