CheckBoxCell不能自定义选择框的画法,它是调用系统默认的。
对于你的需求你可以自己实现CustomCheckBoxCell, 让他继承CheckBoxCell,你只需重新实现它的画法逻辑就可以了。
SampleCode:- public class CustomCheckBoxCell : CheckBoxCell
- {
- protected override void OnPaint(CellPaintingEventArgs e)
- {
- //base.OnPaint(e); Delete CheckBox Drawing.
- e.PaintBackground(e.ClipBounds);
- e.PaintBorder(e.ClipBounds);
- if ((this.IsInEditMode && this.EditedFormattedValue != null && (bool)this.EditedFormattedValue == true)
- || (bool)e.FormattedValue == true)
- {
- e.Graphics.DrawString("X", e.CellStyle.Font, System.Drawing.Brushes.Black, e.CellBounds.Location);
- //Or Draw your image in here.
- }
- }
- }
复制代码 |