如何使用VB.Net为FontBold设置C1FlexGrid样式



如何使C1flexgrid中的行或列具有粗体字体??

我的意思是,我有一个这样的编码:

Com_B1B2.Parameters("Param1").Value = gDate2
Com_B1B2.ParameterCheck = True
OraDA = New OracleDataAdapter(Com_B1B2)
OraDA.Fill(OraDT)
VLX_B1B2.DataSource = OraDT
VLX_B1B2.Cols(0).Width = 0

有人能帮忙吗?

您可以处理C1Flexgrid的OwnerDrawCell事件,然后为所需的行/列分配不同的字体样式。

关于完整的实现,请参阅这篇博客文章。

谨致问候,Mohita

要将任何行/列的字体加粗,可以使用以下代码段:

void MakeColumnBold(int ColNo, C1FlexGrid grid)
{
  CellStyle cs = grid.Cols[ColNo].StyleNew;
  cs.Font = new Font(grid.Font.Name, grid.Font.Size, FontStyle.Bold);
}
void MakeRowBold(int RowNo, C1FlexGrid grid)
{
  CellStyle cs = grid.Rows[RowNo].StyleNew;
  cs.Font = new Font(grid.Font.Name, grid.Font.Size, FontStyle.Bold);
}

我认为最好只定义一次样式,而不是将其复制到每一行:

Dim cs As C1.Win.C1FlexGrid.CellStyle = grid.Styles.Add("FontBold")
cs.Font = New Font(grid.Font.Name, grid.Font.Size, FontStyle.Bold)
'to get styles elsewhere (after created once): grid.styles("FontBold")
grid.SetCellStyle(3, 4, "FontBold") 'set just one cell
grid.Cols(6).Style = cs 'set complete column
grid.Rows(6).Style = cs 'set complete row

最新更新