C# datagridview 标题栏怎么用checkbox的□框框显示?

解决方案 »

  1.   

    应该可以,我估计拖一个窗体,在里面搞上你要弄的口框框做为标题。
    然后的话把这个窗体覆盖在你的datagridview上面,并且要能够根据的表列自动调整这个窗体的每个口框框。反正就是障眼法,我这么猜的,可以多讨论下。
      

  2.   


    可以。主要是两个对象
    DataGridViewColumnHeaderCell
    DGVColumnHeader给你个写好的方法,可以直接向DataGridView添加CheckBox列
    protected bool bColumnSelect = false;
            protected bool bGridViewSelectEnable = false;
            protected void EnableDataGridViewSelect(DataGridView in_dgView)
            {
                DataGridViewCheckBoxColumn column = new DataGridViewCheckBoxColumn();
                {                column.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;//.DisplayedCells;
                    column.FlatStyle = FlatStyle.Standard;
                    column.ThreeState = false;
                    column.CellTemplate = new DataGridViewCheckBoxCell();
                    column.CellTemplate.Style.BackColor = Color.White;
                    DataGridViewColumnHeaderCell headCheckBox = new DataGridViewColumnHeaderCell();
                    //headCheckBox.
                    //column.HeaderCell = new DataGridViewColumnHeaderCell();            }            in_dgView.Columns.Insert(0, column);            DGVColumnHeader dgvColumnheader = new DGVColumnHeader();
                column.HeaderCell = dgvColumnheader;            //dataGridViewUser.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
                //column.ReadOnly = true;            if (!bGridViewSelectEnable)
                {
                    in_dgView.ColumnHeaderMouseClick += new DataGridViewCellMouseEventHandler(this.dataGridViewUser_ColumnHeaderMouseClick);                in_dgView.CellMouseUp += new DataGridViewCellMouseEventHandler(this.dataGridViewUser_CellMouseUp);
                    bGridViewSelectEnable = true;
                }
            }