public void AddDgvTitle(string ColName, string HeaderText, int Width)
        {
            if (_Dgv.Columns.Contains(ColName))
            {
                return;
            }
            DataGridViewColumn colitem = new DataGridViewTextBoxColumn();

            colitem.Name         = colitem.DataPropertyName = ColName;
            colitem.Width        = Width;
            colitem.HeaderText   = HeaderText;
            colitem.DisplayIndex = _Dgv.Columns.Count;
            colitem.ReadOnly     = true;
            colitem.Frozen       = false;
            _Dgv.Columns.Add(colitem);
            HeadColFilter var = HeadColList.Find(a => a.ColName == ColName);

            if (var == null)
            {
                HeadColList.Add(new HeadColFilter()
                {
                    ColName = ColName, FilterStr = ""
                });
                dgvFilterColHeadCell dgvheadercell = new dgvFilterColHeadCell(colitem.HeaderCell, ColFilterType.list.ToString());
                dgvheadercell.AutomaticSortingEnabled = true;
                dgvheadercell.eventFilterEx          += new dgvFilterColHeadCell.delegateFilterEx(dgvheadercell_eventFilterEx);
                colitem.HeaderCell = dgvheadercell;
            }
        }
        private void InitDgv()
        {
            _Dgv.AllowUserToAddRows        = false; //禁止用户添加行;
            _Dgv.AllowUserToDeleteRows     = false; //禁止用户删除行;
            _Dgv.AllowUserToOrderColumns   = false; //允许用户拖动列顺序;
            _Dgv.EnableHeadersVisualStyles = false; //显示格式;
            _Dgv.AutoGenerateColumns       = false;
            _Dgv.MultiSelect                   = false;
            _Dgv.RowHeadersWidth               = 15;
            _Dgv.BorderStyle                   = BorderStyle.Fixed3D;
            _Dgv.ColumnHeadersHeightSizeMode   = DataGridViewColumnHeadersHeightSizeMode.EnableResizing;
            _Dgv.SelectionMode                 = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
            _Dgv.CellMouseDown                += new DataGridViewCellMouseEventHandler(dgv_CellMouseDown);
            _Dgv.CurrentCellDirtyStateChanged += new EventHandler(dgvSelectAll_CurrentCellDirtyStateChanged);
            _Dgv.DataSourceChanged            += new EventHandler(dgv_DataSourceChanged);

            //新增在表头显示行数
            _Dgv.RowPostPaint += _Dgv_RowPostPaint;

            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle = new System.Windows.Forms.DataGridViewCellStyle();
            dataGridViewCellStyle.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;

            _Dgv.DefaultCellStyle = dataGridViewCellStyle;
            _Dgv.Columns.Clear();
            {
                DataGridViewCheckBoxColumn col = new DataGridViewCheckBoxColumn();
                col.Name         = col.DataPropertyName = dgv_chk_tag;
                col.Width        = 10;
                col.HeaderText   = "";
                col.DisplayIndex = 0;
                col.ReadOnly     = false;
                col.Frozen       = true;
                col.Visible      = _IsCheckBox;
                col.SortMode     = DataGridViewColumnSortMode.Automatic;
                _Dgv.Columns.Add(col);
                HeadColFilter var = HeadColList.Find(a => a.ColName == dgv_chk_tag);
                if (var == null)
                {
                    HeadColList.Add(new HeadColFilter()
                    {
                        ColName = dgv_chk_tag, FilterStr = ""
                    });
                    dgvFilterColHeadCell dgvheadercell = new dgvFilterColHeadCell(col.HeaderCell, ColFilterType.Check.ToString());
                    dgvheadercell.AutomaticSortingEnabled = true;
                    dgvheadercell.eventFilterEx          += new dgvFilterColHeadCell.delegateFilterEx(dgvheadercell_eventFilterEx);
                    col.HeaderCell = dgvheadercell;
                }
            }
        }
        public dgvFilterColHeadCell(DataGridViewColumnHeaderCell oldHeaderCell, string _FilterType)
        {
            this.ContextMenuStrip = oldHeaderCell.ContextMenuStrip;
            this.ErrorText        = oldHeaderCell.ErrorText;
            this.Tag         = oldHeaderCell.Tag;
            this.ToolTipText = oldHeaderCell.ToolTipText;
            this.Value       = oldHeaderCell.Value;
            this.ValueType   = oldHeaderCell.ValueType;
            FilterType       = _FilterType;

            if (oldHeaderCell.HasStyle)
            {
                this.Style = oldHeaderCell.Style;
            }
            ColumnDataName = oldHeaderCell.DataGridView.Columns[oldHeaderCell.ColumnIndex].DataPropertyName;
            ColumnName     = oldHeaderCell.DataGridView.Columns[oldHeaderCell.ColumnIndex].Name;
            dgvFilterColHeadCell filterCell =
                oldHeaderCell as dgvFilterColHeadCell;

            if (filterCell != null)
            {
                this.FilteringEnabled                   = filterCell.FilteringEnabled;
                this.AutomaticSortingEnabled            = filterCell.AutomaticSortingEnabled;
                this.DropDownListBoxMaxLines            = filterCell.DropDownListBoxMaxLines;
                this.currentDropDownButtonPaddingOffset =
                    filterCell.currentDropDownButtonPaddingOffset;
                this.ucFilterTop   = filterCell.ucFilterTop;
                this.eventFilterEx = filterCell.eventFilterEx;
            }
            if (_FilterType == ColFilterType.Check.ToString())
            {
                ucFilterTop = new UCCheckSelect();
            }
            else
            {
                ucFilterTop = new UCListSelect();
            }
            this.ucFilterTop.ColDataName = ColumnDataName;
        }
        private void InitDgv()
        {
            _Dgv.AllowUserToAddRows = false;//禁止用户添加行;
            _Dgv.AllowUserToDeleteRows = false;//禁止用户删除行;
            _Dgv.AllowUserToOrderColumns = false;//允许用户拖动列顺序;
            _Dgv.EnableHeadersVisualStyles = false;//显示格式;
            _Dgv.AutoGenerateColumns = false;
            _Dgv.MultiSelect = false;
            _Dgv.RowHeadersWidth = 15;
            _Dgv.BorderStyle = BorderStyle.Fixed3D;
            _Dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing;
            _Dgv.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
            _Dgv.CellMouseDown += new DataGridViewCellMouseEventHandler(dgv_CellMouseDown);
            _Dgv.CurrentCellDirtyStateChanged += new EventHandler(dgvSelectAll_CurrentCellDirtyStateChanged);
            _Dgv.DataSourceChanged += new EventHandler(dgv_DataSourceChanged);

            //新增在表头显示行数
            _Dgv.RowPostPaint += _Dgv_RowPostPaint;

            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle = new System.Windows.Forms.DataGridViewCellStyle();
            dataGridViewCellStyle.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;

            _Dgv.DefaultCellStyle = dataGridViewCellStyle;
            _Dgv.Columns.Clear();
            {
                DataGridViewCheckBoxColumn col = new DataGridViewCheckBoxColumn();
                col.Name = col.DataPropertyName = dgv_chk_tag;
                col.Width = 10;
                col.HeaderText = "";
                col.DisplayIndex = 0;
                col.ReadOnly = false;
                col.Frozen = true;
                col.Visible = _IsCheckBox;
                col.SortMode = DataGridViewColumnSortMode.Automatic;
                _Dgv.Columns.Add(col);
                HeadColFilter var = HeadColList.Find(a => a.ColName == dgv_chk_tag);
                if (var == null)
                {
                    HeadColList.Add(new HeadColFilter() { ColName = dgv_chk_tag, FilterStr = "" });
                    dgvFilterColHeadCell dgvheadercell = new dgvFilterColHeadCell(col.HeaderCell, ColFilterType.Check.ToString());
                    dgvheadercell.AutomaticSortingEnabled = true;
                    dgvheadercell.eventFilterEx += new dgvFilterColHeadCell.delegateFilterEx(dgvheadercell_eventFilterEx);
                    col.HeaderCell = dgvheadercell;

                }
            }
        }
        public void AddDgvTitle(string ColName, string HeaderText, int Width)
        {
            if (_Dgv.Columns.Contains(ColName))
            {
                return;
            }
            DataGridViewColumn colitem = new DataGridViewTextBoxColumn();
            colitem.Name = colitem.DataPropertyName = ColName;
            colitem.Width = Width;
            colitem.HeaderText = HeaderText;
            colitem.DisplayIndex = _Dgv.Columns.Count;
            colitem.ReadOnly = true;
            colitem.Frozen = false;
            _Dgv.Columns.Add(colitem);
            HeadColFilter var = HeadColList.Find(a => a.ColName == ColName);

            if (var==null)
            {
                HeadColList.Add(new HeadColFilter() {ColName=ColName,FilterStr="" });
                dgvFilterColHeadCell dgvheadercell = new dgvFilterColHeadCell(colitem.HeaderCell, ColFilterType.list.ToString());
                dgvheadercell.AutomaticSortingEnabled = true;
                dgvheadercell.eventFilterEx += new dgvFilterColHeadCell.delegateFilterEx(dgvheadercell_eventFilterEx);
                colitem.HeaderCell = dgvheadercell;
            }
        }