在DataGridView中格式化单个单元格,如粗体或斜体 [英] Format a single cell in DataGridView like Bold or Italic
本文介绍了在DataGridView中格式化单个单元格,如粗体或斜体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在某种情况下在DataGridView中格式化单个单元格,我想将该单元格的字体加粗,而另一些则用斜体,
该怎么做?
如果有人知道,请给我解释.
谢谢
I want to format a single cell in DataGridView on some condition, i want to bold the font of that cell and some in italic,
how to do this?
if Any one knows please explain me.
thank you
推荐答案
Private Sub dgvClsJoin_CurrentCellDirtyStateChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView1.CurrentCellDirtyStateChanged
Try
If (DataGridView1.IsCurrentCellDirty) Then
DataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit)
If DataGridView1.CurrentCell.Value <> 0 Then 'your condition
If DataGridView1.CurrentCell.Value = 1 Then
DataGridView1.CurrentCell.Style.Font = New Font("Arial", 12, FontStyle.Bold)
End If
End If
End If
Catch
End Try
End Sub
这篇关于在DataGridView中格式化单个单元格,如粗体或斜体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文