Пример #1
0
        /// <summary>
        /// 设置可编辑列类型
        /// </summary>
        /// <param name="index">列索引</param>
        /// <param name="colStyle">列类型</param>
        public bool SetEditColumnStyle(int index, EditColumnStyle colStyle)
        {
            Debug.Assert(index > -1 && index < this.Columns.Count);

            if (_colCtrlDic.ContainsKey(index))
            {
                return(false);
            }
            else
            {
                switch (colStyle)
                {
                case EditColumnStyle.StringTextBox:
                    NormalCharTextBox txtBox = new NormalCharTextBox();
                    InitTextBox(txtBox);

                    _colCtrlDic.Add(index, txtBox);
                    break;

                case EditColumnStyle.IntTextBox:
                    IntTextBox txtIntBox = new IntTextBox();
                    InitTextBox(txtIntBox);

                    _colCtrlDic.Add(index, txtIntBox);
                    break;

                case EditColumnStyle.DoubleTextBox:
                    DoubleTextBox txtDoubleBox = new DoubleTextBox();
                    InitTextBox(txtDoubleBox);

                    _colCtrlDic.Add(index, txtDoubleBox);
                    break;

                case EditColumnStyle.CombBox:
                    ComboBox cmbBox = new ComboBox();
                    cmbBox.Visible       = false;
                    cmbBox.DropDownStyle = ComboBoxStyle.DropDownList;
                    cmbBox.FlatStyle     = FlatStyle.Standard;
                    cmbBox.Leave        += new EventHandler(combBox_Leave);
                    this.Controls.Add(cmbBox);
                    _colCtrlDic.Add(index, cmbBox);
                    break;

                case EditColumnStyle.DateTimePicker:
                    DateTimePicker dtp = new DateTimePicker();
                    dtp.Format  = DateTimePickerFormat.Custom;
                    dtp.Visible = false;
                    dtp.Leave  += new EventHandler(dateTime_Leave);
                    this.Controls.Add(dtp);
                    _colCtrlDic.Add(index, dtp);
                    break;

                default:
                    break;
                }

                return(true);
            }
        }
Пример #2
0
        /// <summary>
        /// 删除限制输入字符
        /// </summary>
        /// <param name="index">列号</param>
        /// <param name="c">限制字符</param>
        /// <returns></returns>
        public bool RemoveStringColumnUnallowedChar(int index, char c)
        {
            Debug.Assert(index > -1 && index < this.Columns.Count);

            if (_colCtrlDic.ContainsKey(index))
            {
                if (_colCtrlDic[index] is NormalCharTextBox)
                {
                    NormalCharTextBox norTxtCtrl = _colCtrlDic[index] as NormalCharTextBox;

                    norTxtCtrl.RemoveUnallowedChar(c);

                    return(true);
                }
            }

            return(false);
        }
Пример #3
0
        /// <summary>
        /// 设置最大输入字符长度
        /// </summary>
        /// <param name="index">列号</param>
        /// <param name="maxLen">最大输入长度</param>
        /// <returns></returns>
        public bool SetStringColumnLength(int index, uint maxLen)
        {
            Debug.Assert(index > -1 && index < this.Columns.Count);

            if (_colCtrlDic.ContainsKey(index))
            {
                if (_colCtrlDic[index] is NormalCharTextBox)
                {
                    NormalCharTextBox norTxtCtrl = _colCtrlDic[index] as NormalCharTextBox;

                    norTxtCtrl.MaxInputLength = maxLen;

                    return(true);
                }
            }

            return(false);
        }