请尝试下边实例代码:- private void gcMultiRow1_CellPainting(object sender, CellPaintingEventArgs e)
- {
- if (e.Scope == CellScope.Row)
- {
- if (e.Value != null && e.Value is string)//In here, you can filter target cell by e.CellIndex/CellName
- {
- string str = (string)e.Value;
- if (str.Length > 12)
- {
- e.PaintBackground(e.ClipBounds);
- str = str.Remove(0, str.Length - 12);
- using (SolidBrush brush = new SolidBrush(e.CellStyle.ForeColor))
- {
- var strSize = e.Graphics.MeasureString(str, e.CellStyle.Font);
- e.Graphics.DrawString(str, e.CellStyle.Font, brush, new PointF(e.CellBounds.Location.X, e.CellBounds.Location.Y + (e.CellBounds.Height - strSize.Height) / 2));
- }
- e.PaintBorder(e.ClipBounds);
- e.PaintCellNoteTriangleSymbol(e.ClipBounds);
- e.PaintErrorIcon(e.ClipBounds);
- e.PaintWaveLine(e.ClipBounds);
- e.Handled = true;
- }
- }
- }
- }
复制代码 |