1 DataGridView 主要用到datagridview 的单元格重画事件
protected override void OnCellPainting(System
Windows
DataGridViewCellPaintingEventArgs e) 还有 GDI 画图, 复合表头如下图: 合并行的话同样是使用了其单元格重画事件:private void DrawCell(DataGridViewCellPaintingEventArgs e) 对上下单元格相同内容的合并
同样是通过 GDI 实现
具体的请见下面的源码 效果图如下: 2 复合表头源码如下: public partial class HeaderUnitView : DataGridView { private TreeView[] _columnTreeView; private ArrayList _columnList = new ArrayList(); private int _cellHeight = 17; public int CellHeight { get { return _cellHeight; } set { _cellHeight = value; } } private int _columnDeep = 1; private bool HscrollRefresh = false; 3 /// /// 水平滚动时是否刷新表头,数据较多时可能会闪烁,不刷新时可能显示错误 /// [Description("水平滚动时是否刷新表头,数据较多时可能会闪烁,不刷新时可能显示错误")] public bool RefreshAtHscroll { ge