本文整理汇总了VB.NET中System.Windows.Forms.DataGridViewCell.ErrorText属性的典型用法代码示例。如果您正苦于以下问题:VB.NET DataGridViewCell.ErrorText属性的具体用法?VB.NET DataGridViewCell.ErrorText怎么用?VB.NET DataGridViewCell.ErrorText使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Windows.Forms.DataGridViewCell
的用法示例。
在下文中一共展示了DataGridViewCell.ErrorText属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: CheckTrack
Private Sub dataGridView1_CellValidating(ByVal sender As Object, _
ByVal e As _
DataGridViewCellValidatingEventArgs) _
Handles dataGridView1.CellValidating
Dim column As DataGridViewColumn = _
dataGridView1.Columns(e.ColumnIndex)
If column.Name = "Track" Then
CheckTrack(e)
ElseIf column.Name = "Release Date" Then
CheckDate(e)
End If
End Sub
Private Shared Sub CheckTrack(ByVal newValue As DataGridViewCellValidatingEventArgs)
If String.IsNullOrEmpty(newValue.FormattedValue.ToString()) Then
NotifyUserAndForceRedo("Please enter a track", newValue)
ElseIf Not Integer.TryParse( _
newValue.FormattedValue.ToString(), New Integer()) Then
NotifyUserAndForceRedo("A Track must be a number", newValue)
ElseIf Integer.Parse(newValue.FormattedValue.ToString()) < 1 Then
NotifyUserAndForceRedo("Not a valid track", newValue)
End If
End Sub
Private Shared Sub NotifyUserAndForceRedo(ByVal errorMessage As String, ByVal newValue As DataGridViewCellValidatingEventArgs)
MessageBox.Show(errorMessage)
newValue.Cancel = True
End Sub
Private Sub CheckDate(ByVal newValue As DataGridViewCellValidatingEventArgs)
Try
DateTime.Parse(newValue.FormattedValue.ToString()).ToLongDateString()
AnnotateCell(String.Empty, newValue)
Catch ex As FormatException
AnnotateCell("You did not enter a valid date.", newValue)
End Try
End Sub
Private Sub AnnotateCell(ByVal errorMessage As String, _
ByVal editEvent As DataGridViewCellValidatingEventArgs)
Dim cell As DataGridViewCell = _
dataGridView1.Rows(editEvent.RowIndex).Cells( _
editEvent.ColumnIndex)
cell.ErrorText = errorMessage
End Sub