Torna al Thread
Private Sub DataGridView1_CellPainting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellPaintingEventArgs) Handles DataGridView1.CellPainting
If Me.DataGridView1.Rows(e.RowIndex).Cells.Item(4).Value Is "Arrivo" Then
e.CellStyle.BackColor = Color.LightGreen
ElseIf Me.DataGridView1.Rows(e.RowIndex).Cells.Item(4).Value Is "Partenza" Then
e.CellStyle.BackColor = Color.Red
Dim buttonCell As DataGridViewDisableButtonCell = CType(DataGridView1.Rows(e.RowIndex).Cells(0),DataGridViewDisableButtonCell)
buttonCell.Enabled = False
DataGridView1.Invalidate()
End If
End Sub
Public Class DataGridViewDisableButtonCell
Inherits DataGridViewButtonCell
Private enabledValue As Boolean
Public Property Enabled() As Boolean
Get
Return enabledValue
End Get
Set(ByVal value As Boolean)
enabledValue = value
End Set
End Property
' Override the Clone method so that the Enabled property is copied.
Public Overrides Function Clone() As Object
Dim Cell As DataGridViewDisableButtonCell = _
CType(MyBase.Clone(), DataGridViewDisableButtonCell)
Cell.Enabled = Me.Enabled
Return Cell
End Function
' By default, enable the button cell.
Public Sub New()
Me.enabledValue = True
End Sub
End Class
Sub dataGridView1_CurrentCellDirtyStateChanged( _
ByVal sender As Object, ByVal e As EventArgs) _
Handles DataGridView1.CurrentCellDirtyStateChanged
If dataGridView1.IsCurrentCellDirty Then
dataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit)
End If
End Sub