如何使devexpress gridcontrol's指示器显示粗体文本

本文关键字:显示 指示器 文本 devexpress 何使 gridcontrol | 更新日期: 2023-09-27 18:07:13

如何使显示文本在devexpress gridcontrol的指示器粗体?

此处更改指示单元格样式也会更改背景颜色。但我只想让指示单元格显示粗体文本,并使用默认背景色。

    e.Appearance.FillRectangle(e.Cache, e.Bounds);
    e.Appearance.DrawString(e.Cache, e.Info.DisplayText, e.Bounds, 
          new Font(e.Appearance.Font.FontFamily,10,FontStyle.Bold), 
          new StringFormat());
    e.Handled = true;

如何使devexpress gridcontrol's指示器显示粗体文本

您可以设置网格中聚焦行的样式。Grid => GridView => Appearance => FocusedRow => Font =>粗体设置为true

我们使用以下代码:

_gridView.RowCellStyle += GridViewRowCellStyle;
void GridViewRowCellStyle(object sender, RowCellStyleEventArgs e)
{
    FontStyle fs = e.Appearance.Font.Style;
    fs |= FontStyle.Bold;
    e.Appearance.Font = new Font(e.Appearance.Font, fs);
}

如果你有编辑器,添加如下:

_gridView.ShownEditor += GridViewShownEditor;
void GridViewShownEditor(object sender, EventArgs e)
{
    FontStyle fs = _gridView.ActiveEditor.Font.Style;
    fs |= FontStyle.Bold;
    _gridView.ActiveEditor.Font = new Font(_gridView.ActiveEditor.Font, fs);
}

指示符也一样:

_gridView.CustomDrawRowIndicator += GridViewCustomDrawRowIndicator;
void GridViewCustomDrawRowIndicator(object sender, EventArgs e)
{
    FontStyle fs = e.Appearance.Font.Style;
    fs |= FontStyle.Bold;
    e.Appearance.Font = new Font(e.Appearance.Font, fs);
}