RadGridView更改ColumnGroup标题字体大小

时间:2016-02-24 07:39:06

标签: c# winforms telerik-window

我有一个gridview,我将其中的一些列分组..

以下是我对它们进行分组的方式:

composer require

我是否可以更改 void gvDetailsDefinition() { ColumnGroupsViewDefinition view = new ColumnGroupsViewDefinition(); view.ColumnGroups.Add(new GridViewColumnGroup()); view.ColumnGroups[0].Rows.Add(new GridViewColumnGroupRow()); view.ColumnGroups[0].Rows[0].Columns.Add(gvSalesForecastDetails.Columns["ItemCode"]); view.ColumnGroups[0].Rows[0].Columns.Add(gvSalesForecastDetails.Columns["ItemDescription"]); view.ColumnGroups[0].Rows[0].Columns.Add(gvSalesForecastDetails.Columns["MeasurementUnitSelection"]); view.ColumnGroups.Add(new GridViewColumnGroup("January")); view.ColumnGroups[1].Rows.Add(new GridViewColumnGroupRow()); view.ColumnGroups[1].Rows[0].Columns.Add(gvSalesForecastDetails.Columns["JanuaryQuantity"]); view.ColumnGroups[1].Rows[0].Columns.Add(gvSalesForecastDetails.Columns["JanuaryVolume"]); view.ColumnGroups.Add(new GridViewColumnGroup("February")); view.ColumnGroups[2].Rows.Add(new GridViewColumnGroupRow()); view.ColumnGroups[2].Rows[0].Columns.Add(gvSalesForecastDetails.Columns["FebruaryQuantity"]); view.ColumnGroups[2].Rows[0].Columns.Add(gvSalesForecastDetails.Columns["FebruaryVolume"]); gvSalesForecastDetails.ViewDefinition = view; } 的{​​{1}}?

这是结果:

enter image description here

1 个答案:

答案 0 :(得分:0)

您必须使用ViewCellFormatting事件:

private void gvSalesForecastDetails_ViewCellFormatting(object sender, CellFormattingEventArgs e)
    {
        if (e.CellElement is GridHeaderCellElement)
        {
            if ((((string)(e.CellElement).Value) == "January" || ((string)(e.CellElement).Value) == "Feberuary" || ((string)(e.CellElement).Value) == "March"))
            {
                e.CellElement.Font = BOLD_FONT;//the font u want

                e.CellElement.ForeColor = Color.SteelBlue;
                e.CellElement.GradientStyle = GradientStyles.Solid;
                e.CellElement.DrawFill = true;
                e.CellElement.BackColor = Color.White;
            }
            else
            {
                e.CellElement.ResetValue(LightVisualElement.FontProperty, ValueResetFlags.Local);
                e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
                e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
                e.CellElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local);
                e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local);
            }
        }
    }