[英]Custom DataGridView Column In Visual Basic?
我試圖創建一個自定義的DataGridViewColumn和的DataGridViewCell,並發現該文章是一個很好的資源。 創建完DataGridViewColumn類和DataGridViewCell類后,但是,當我嘗試編輯列的類型時,新的自定義類不會顯示為選項之一。 我的DataGridViewScheduleColumn繼承了DataGridViewColumn,所以我不太確定自己在做什么錯。 我還需要做些什么來將這些類公開給IDE?
謝謝。
這是自定義列類
Public Class DataGridViewScheduleColumn
Inherits DataGridViewColumn
Public Sub New()
Me.CellTemplate = New DataGridViewScheduleCell
Me.ReadOnly = True
End Sub
Public MaxValue As Long
Private needsRecalc As Boolean = True
Public Sub calcMaxValue()
If needsRecalc Then
Dim colIndex As Integer = Me.DisplayIndex
For rowIndex As Integer = 0 To Me.DataGridView.Rows.Count - 1
Dim row As DataGridViewRow = Me.DataGridView.Rows(rowIndex)
MaxValue = Math.Max(MaxValue, CLng(row.Cells(colIndex).Value))
Next
needsRecalc = False
End If
End Sub
末級
您自定義的DGV列和單元格代碼是否在與要使用它們的表單不同的項目中?
如果是這樣,則需要從Form項目中添加對自定義DGV列項目的引用。 為此,右鍵單擊您的Form項目,從上下文菜單中選擇“添加引用...”,然后添加DGV列項目(或項目的輸出)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.