Ejemplo n.º 1
0
        public DGV_ComboBoxCell()
            : base()
        {
            _al = null;
              _displayMember = string.Empty;
              _valueMember = string.Empty;
              _editingComboBox = null;

              _ddMaxItems = 0;
              _ddWidth = 0;
        }
Ejemplo n.º 2
0
        public override void InitializeEditingControl(int rowIndex, object
        initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
        {
            // Set the value of the editing control to the current cell value.
              base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle);

              DGV_ComboBoxEditingControl ctl = DataGridView.EditingControl as DGV_ComboBoxEditingControl;
              if (ctl != null)
              {
            ctl.SelectedIndexChanged -= new EventHandler(DoSelectedIndexChanged);

            ctl.DataSource = null;
            //ctl.Items.Clear();

            ctl.DropDownStyle = ComboBoxStyle.DropDown;
            if (_ddMaxItems > 0)
              ctl.MaxDropDownItems = _ddMaxItems;
            if (_ddWidth > 0)
              ctl.DropDownWidth = _ddWidth;
            ctl.DataSource = _al;
            if (ctl.Items.Count > 0)
            {
              ctl.DisplayMember = _displayMember;
              ctl.ValueMember = _valueMember;
            }
            ctl.pFindByLettersStart = FindByLettersStart;
            ctl.pFindByLettersLength = FindByLettersLength;
            ctl.pIsCaseSensitive = FindIsCaseSensitive;

            string s = initialFormattedValue as string;
            if (s == null)
              s = string.Empty;
            ctl.Text = s;

            _editingComboBox = ctl;
            _editingComboBox.EditingControlRowIndex = rowIndex;

            _editingComboBox.SelectedIndexChanged += new EventHandler(DoSelectedIndexChanged);
              }
        }
Ejemplo n.º 3
0
        public override void DetachEditingControl()
        {
            ComboBox cbo = this.DataGridView.EditingControl as ComboBox;
              if (cbo != null && cbo.Text.Length > 0)
              {
            bool flg = true;
            foreach (object oi in cbo.Items)
            {
              string si = oi as string;
              if (si != null && si.Equals(cbo.Text))
              {
            flg = false;
            break;
              }
            }

            if (flg && _templateComboBoxColumn != null)
            {
              _templateComboBoxColumn.OnEnterNewText(cbo.Text);
            }

              }

              if(cbo != null)
            cbo.SelectedIndexChanged -= new EventHandler(DoSelectedIndexChanged);

              _editingComboBox = null;
              base.DetachEditingControl();
        }