Exemplo n.º 1
0
        /// <summary>
        /// 初始化控件
        /// </summary>
        /// <param name="form"></param>
        /// <param name="dgv"></param>
        /// <param name="cls"></param>
        /// <returns></returns>
        private bool Init(DataGridView dgv, bool isUsingCheck)
        {
            if (dgv == null)
            {
                return(false);
            }

            myDGV = dgv;
            dgv.AutoGenerateColumns = false;
            dgv.AutoSizeRowsMode    = DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders;
            dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;

            InitExistColumns8Tag(dgv);                                // 对已存在的列进行处理

            if (CheckBoxIndex < 0 && isUsingCheck && !ColumnHasChk()) // 自动创建多选列
            {
                checkColumn = DGViewUtil.CreateCheckBoxColumn(20, true);
                myDGV.Columns.Add(checkColumn);
            }


            DataGridViewCheckBoxColumn chk = DGVColumnInfo.CreateAndInitControls(clsList, dgv); // 创建不存在的列并设置相关信息

            if (chk != null)                                                                    // 自动创建多选列
            {
                checkColumn = chk;
            }

            OnResize();     // 设置列宽
            return(true);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 常见列
 /// </summary>
 /// <param name="info"></param>
 /// <returns></returns>
 private static DataGridViewColumn CreateControl(DGVColumnInfo info)
 {
     if (info.Type.ToLower().Equals("chk"))
     {
         return(DGViewUtil.CreateCheckBoxColumn());
     }
     else if (info.Type.ToLower().Equals("chk_head"))
     {
         return(DGViewUtil.CreateCheckBoxColumn(20, true));
     }
     else
     {
         DataGridViewColumn ex = new DataGridViewTextBoxColumn();
         ex.Tag = info.ColumnID;
         if (info.IsShow == 0)
         {
             ex.Visible = false;
         }
         ex.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
         return(ex);
     }
 }