List som datasource til datagridview
Hej,Er der nogen der kan hjælpe med en løsning.
Jeg kan ikke få data fra min liste vist i en datagrid.
Jeg får oprettet 6 blanke felter med overskiften status.
Public Class Devices
Public DeviceId As Integer
Public Extension As String
Public Status As String
Public Sub New(ByVal DeviceId As Integer, ByVal Extension As String, ByVal Status As String)
Me.DeviceId = DeviceId
Me.Extension = Extension
Me.Status = Status
End Sub
End Class 'Devices
Private Sub FillGrid()
Dim Device As List(Of Devices)
Device = New List(Of Devices)
Device.Add(New Devices(1, "300", "Ledig"))
Device.Add(New Devices(2, "301", "Ringetone"))
Device.Add(New Devices(3, "302", "Ledig"))
Device.Add(New Devices(4, "303", "Taler med 44640105"))
Device.Add(New Devices(5, "304", "Ledig"))
Device.Add(New Devices(6, "304", "Indkommende opkald"))
Dim column As DataGridViewColumn = _
New DataGridViewTextBoxColumn()
column.DataPropertyName = "Status"
column.Name = "Status"
DataGridView1.Columns.Add(column)
DataGridView1.AutoGenerateColumns = False
DataGridView1.AutoSize = True
Dim DeviceBindingSource As New BindingSource
DeviceBindingSource.DataSource = Device
DataGridView1.DataSource = DeviceBindingSource
End Sub
Vh.
Thomas