System.Windows.Forms.ComboBox

咨询一下:ComboBox 实现可以编辑文字,但是不修改Item的值?

补充一下,我是用的DataGridView中的DataGridViewComboBoxCell,现在实现了编辑的功能,但是必须在item里添加

我通过重写DataGridViewComboBoxCell类 实现了类似资源代下载网功能

public override void InitializeEditingControl(int rowIndex, object initialFormattedValue,

            DataGridViewCellStyle dataGridViewCellStyle)

        {

            base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle);

 

            comboBox = (System.Windows.Forms.ComboBox)base.DataGridView.EditingControl;

            if (comboBox != null)

            {

                comboBox.DropDownStyle = ComboBoxStyle.DropDown;

                comboBox.AutoCompleteMode = AutoCompleteMode.Suggest;

                comboBox.Validating += new CancelEventHandler(comboBox_Validating);

            }

        }

修改TextBox模板,加一个按钮,点击后创建一个Dropdown之类的控件

可行,我试试

 

 ComboBox sel = new ComboBox();

            sel.IsEditable = true;

谢谢但是请先看一下问题,我是System.Windows.Forms.ComboBox,而且我可以通过DropDownStyle设置他的属性。现 在是想不添加item的同时给DataGridViewComboBoxCell.Value附上combobox.Text的值。
我还发现了,DataGridViewComboBoxCell.Value的值必须是DataGridViewComboBoxCell.item中存在的值不然会报错。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-12
  • 2022-01-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-25
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案