1
我想格式化關於對象的「status」屬性的datagridview的行。 FormatRow函數可以接收任何類型的對象。我想出了這個功能:函數中的泛型
Private Sub FormatRow(Of T)()
For Each row As DataGridViewRow In dgvHistory.Rows
Dim obj As T = CType(row.DataBoundItem, T)
If obj.**Status** = BLL.Configuration.HISTORY_STATUS_ACTIVE Then
row.DefaultCellStyle.ForeColor = Color.Green
row.DefaultCellStyle.Font = New Font(Control.DefaultFont, FontStyle.Bold)
End If
Next
End Sub
但我不能讓它成爲正確的方式。在IF語句中,「status」屬性不可用,因爲我的行對象沒有正確輸出。
有什麼想法?謝謝。
它的工作原理!謝謝你的提示! – Dams