绑定一个Class属性,该列表返回一个列表到DataGridViewComboBoxColumn

时间:2011-03-12 01:54:27

标签: vb.net datagridview combobox properties bind

我有一个在多个路径上找到的文件名。我想以DGV的格式向用户呈现这些数据。我有一个DGV,名称有一个文本框列,路径有另一个组合框列。我无法将组合框列绑定到返回路径的类的属性。

非常感谢任何帮助。

Public Class fileTest
    Public Property FileName As String
    Public Property Paths As String()

    Public Sub New(ByRef _name As String, ByVal _paths As String())
        Me.FileName = _name
        Me.Paths = _paths
    End Sub

End Class

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim fileList As New BindingList(Of fileTest)

    fileList.Add(New fileTest("TEST", {"ABC", "123"}))

    Me.DataGridView1.AutoGenerateColumns = False

    Me.DataGridView1.DataSource = fileList
    Me.DataGridView1.Columns("FileName").DataPropertyName = "FileName"
    CType(Me.DataGridView1.Columns("Paths"), DataGridViewComboBoxColumn).DataPropertyName = "Path"

End Sub

1 个答案:

答案 0 :(得分:0)

DataGridViewComboBoxColumn太可怕了。太可怕了。

我们最终放弃了使用它,现在只需将标准的Combobox悬浮在网格上。