我有2个新班级
Public Class ColCust
Inherits DataGridViewColumn
Dim clsCellText As New CellCust
Public Sub New()
Me.CellTemplate = clsCellText
End Sub
End Class
Public Class CellCust
Inherits DataGridViewTextBoxCell
End Class
在主窗体上我有一个网格,我试图使用新类
With dg6
.Columns.Clear()
.Rows.Clear()
For iCol As Integer = 0 To 4
Dim col As New ColCust
.Columns.Add(col)
Next
.Rows.Add(New String() {"1"})
.Rows.Add(New String() {"2"})
.Rows.Add(New String() {"3"})
.Rows.Add(New String() {"4"})
Me.Controls.Add(dg6)
End With
直到现在一切正常, 但在这里我得到了错误
无法投射类型的对象 ' System.Windows.Forms.DataGridViewTextBoxColumn'输入 ' Test.ColCust'
有什么问题?
Dim colText As DataGridViewTextBoxColumn
colText = dg6.Columns(0)