Public Class Category Private _Data As DataTable Public Property Data() As DataTable Get Return _Data End Get Set(ByVal value As DataTable) _Data = value End Set End Property Private _Name As String Public Property Name() As String Get Return _Name End Get Set(ByVal value As String) _Name = value End Set End Property End Class
Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim categories As New Collection 'Création de 3 objets thecategory For a = 1 To 3 Dim theCategory As New Category Dim theData As New DataTable theData.Columns.Add("column" & a * 2) theData.Columns.Add("column" & a * 4) theData.Rows.Add() theData.Rows.Item(0).Item(0) = "Row test" & a theCategory.Name = "Name test" & a theCategory.Data = theData 'Ajout à la collection categories.Add(theCategory) theData = Nothing theCategory = Nothing Next 'Liaison Me.lblName.DataBindings.Add(New System.Windows.Forms.Binding("Text", categories, "Name")) Me.dgvCategories.DataBindings.Add(New System.Windows.Forms.Binding("DataSource", categories, "Data")) DataRepeater1.DataSource = Nothing DataRepeater1.DataSource = categories End Sub End Class
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question