本文整理汇总了VB.NET中System.Windows.Forms.DataGridViewCellFormattingEventArgs.FormattingApplied属性的典型用法代码示例。如果您正苦于以下问题:VB.NET DataGridViewCellFormattingEventArgs.FormattingApplied属性的具体用法?VB.NET DataGridViewCellFormattingEventArgs.FormattingApplied怎么用?VB.NET DataGridViewCellFormattingEventArgs.FormattingApplied使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Windows.Forms.DataGridViewCellFormattingEventArgs
的用法示例。
在下文中一共展示了DataGridViewCellFormattingEventArgs.FormattingApplied属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: ShortFormDateFormat
Private Sub dataGridView1_CellFormatting(ByVal sender As Object, _
ByVal e As DataGridViewCellFormattingEventArgs) _
Handles dataGridView1.CellFormatting
' If the column is the Artist column, check the
' value.
If Me.dataGridView1.Columns(e.ColumnIndex).Name _
= "Artist" Then
If e.Value IsNot Nothing Then
' Check for the string "pink" in the cell.
Dim stringValue As String = _
CType(e.Value, String)
stringValue = stringValue.ToLower()
If ((stringValue.IndexOf("pink") > -1)) Then
e.CellStyle.BackColor = Color.Pink
End If
End If
ElseIf Me.dataGridView1.Columns(e.ColumnIndex).Name _
= "Release Date" Then
ShortFormDateFormat(e)
End If
End Sub
'Even though the date internaly stores the year as YYYY, using formatting, the
'UI can have the format in YY.
Private Shared Sub ShortFormDateFormat(ByVal formatting As DataGridViewCellFormattingEventArgs)
If formatting.Value IsNot Nothing Then
Try
Dim dateString As System.Text.StringBuilder = New System.Text.StringBuilder()
Dim theDate As Date = DateTime.Parse(formatting.Value.ToString())
dateString.Append(theDate.Month)
dateString.Append("/")
dateString.Append(theDate.Day)
dateString.Append("/")
dateString.Append(theDate.Year.ToString().Substring(2))
formatting.Value = dateString.ToString()
formatting.FormattingApplied = True
Catch notInDateFormat As FormatException
' Set to false in case there are other handlers interested trying to
' format this DataGridViewCellFormattingEventArgs instance.
formatting.FormattingApplied = False
End Try
End If
End Sub
开发者ID:VB.NET开发者,项目名称:System.Windows.Forms,代码行数:46,代码来源:DataGridViewCellFormattingEventArgs.FormattingApplied