DevExpress GridView 列标题文字设置

DevExpress GridControl 的列标题文字中包含上下标和特殊字符

如下图:


代码如下:

        private void gridView1_CustomDrawColumnHeader(object sender, DevExpress.XtraGrid.Views.Grid.ColumnHeaderCustomDrawEventArgs e)
        {
            float startX = (e.Bounds.Left + e.Bounds.Right) / 2;
            float startY = e.Bounds.Top;
            e.Info.Caption = "";
            e.Painter.DrawObject(e.Info);
            // Draw sigma
            Font symbol = new Font("Symbol", gridColumn1.AppearanceHeader.Font.Size);
            e.Graphics.DrawString("s", symbol, Brushes.Black, startX, startY);

            // Set next startX
            startX += e.Graphics.MeasureString("s", symbol).Width - 2;

            // Draw prim
            e.Graphics.DrawString("'", gridColumn1.AppearanceHeader.Font, Brushes.Black, startX, startY);

            // Draw c
            Font subScript = new Font(gridColumn1.AppearanceHeader.Font.OriginalFontName, 
                gridColumn1.AppearanceHeader.Font.Size - 2);
            e.Graphics.DrawString("c", subScript, Brushes.Black, startX, startY + 7);
            e.Handled = true;
        }

你可能感兴趣的:(DevExpress GridView 列标题文字设置)