Custom Data Sources

Although the data set is a popular data source, it's by no means the only one. Any custom type can be a data source.

Custom Item Data Sources

The requirements of an item data source are only that it expose one or more public properties:

 ' Expose two properties for binding Class NameAndNumber Public Property Name() As String Get Return myName End Get Set myName = Value End Set End Property Public Property Number() As Integer Get Return myNumber End Get Set myNumber = Value End Set End Property Dim myName As String = "Chris" Dim myNumber As Integer = 452 End Class Dim source As NameAndNumber = New NameAndNumber() Sub CustomItemDataSourceForm_Load(sender As Object, e As EventArgs) ' Bind to public properties textBox1.DataBindings.Add("Text", ...

Get Windows Forms Programming in Visual Basic .NET now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.