使用CellFormatting和CellParsing事件可以定制任何Format的逻辑。
我写了一个例子,让Cell在编辑的时候自动在数字后边加个“元”字。你可以参考这段代码定制你的Format逻辑。- Private Sub GcMultiRow1_CellFormatting(sender As Object, e As GrapeCity.Win.MultiRow.CellFormattingEventArgs) Handles GcMultiRow1.CellFormatting
- If e.Value IsNot Nothing Then
- e.Value = e.Value.ToString() + "元"
- e.FormattingApplied = True
- End If
- End Sub
- Private Sub GcMultiRow1_CellParsing(sender As Object, e As GrapeCity.Win.MultiRow.CellParsingEventArgs) Handles GcMultiRow1.CellParsing
- If e.Value IsNot Nothing Then
- Dim text = e.Value.ToString()
- If text.EndsWith("元") Then
- text = text.Substring(0, text.Length - 1)
- End If
- Dim intValue As Int32
- Int32.TryParse(text, intValue)
- e.Value = intValue
- e.ParsingApplied = True
- End If
- End Sub
复制代码 |