/// <summary> /// The dataGrid1.IndicatorTitle.CellPaint event handler /// Draw question mark in question mark area, /// reduce the area size of standard rendering, /// than call default paint handler. /// </summary> private void dataGrid1_IndicatorTitle_CellPaint(object sender, BaseGridCellPaintEventArgs e) { //PaintBackground Rectangle custBackRect = e.ClientRect; custBackRect.Width = 10; if (custBackRect.Contains(e.InCellMousePos)) { e.Graphics.FillRectangle(new SolidBrush(Color.BurlyWood), custBackRect); } else { e.Graphics.FillRectangle(new SolidBrush(SystemColors.ButtonFace), custBackRect); } EhLibUtils.DrawText(e.Graphics, "?", new Font(dataGrid1.Font.FontFamily, 5), custBackRect, SystemColors.WindowText, HorizontalAlignment.Center, VerticalAlignment.Center, 0); //PaintForeground Rectangle newBackgroundRect = e.ClientRect; newBackgroundRect.X = newBackgroundRect.X + 10; newBackgroundRect.Width = newBackgroundRect.Width - 10; e.ClientRect = newBackgroundRect; e.PaintBackground(e); e.PaintForeground(e); e.Handled = true; }
// // Event Handlers // private void colCPUUsage_Title_CellPaint(object sender, EhLib.WinForms.DataGridTitleCellPaintEventArgs e) { e.Paint(e); Rectangle drawRect = e.ClientRect; drawRect = EhLib.WinForms.EhLibUtils.CopyChangeRectangle(drawRect, 2, 2, -4, -2); HorizontalAlignment horzAlign; if ((e.State & EhLib.WinForms.BasePaintCellStates.RowHotTrack) != 0) { horzAlign = HorizontalAlignment.Left; } else { horzAlign = HorizontalAlignment.Right; } string text = cpuUsageTotalPercent.ToString("0") + " %"; EhLibUtils.DrawText(e.Graphics, text, titlePercentFont, drawRect, gridProcessList.Title.ForeColor, horzAlign, VerticalAlignment.Top, 0); e.Handled = true; }