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

时间:2015-08-11 09:31:38

标签: c# winforms devexpress gridcontrol

如何在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;

2 个答案:

答案 0 :(得分:2)

您可以在网格中设置焦点行的样式。网格=> GridView =>外观=> FocusedRow =>字体=>大胆设置为真。

答案 1 :(得分:1)

我们使用此代码:

_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);
}
相关问题