在有人将此标记为重复之前,请注意,这与这里、这里和这里所提出的问题不同。
当您的DataGridView
中有两个或更多DataGridViewComboBoxColumn
,其中一个下拉列表当前处于打开状态时,单击另一列的下拉按钮不会打开该下拉列表。相反,您仍然需要点击两次。第一次单击用于隐藏已经打开的下拉列表,第二次单击才会打开您单击的下拉列表。
请注意,在EditOnEnter
模式开启时需要进行两次单击;否则,您将需要执行三次单击才能完成此操作。我也尝试了ContentClick事件,但没有任何收获。
那么,在我网格中有多个DataGridViewComboBoxColumn
的情况下,如何使用单击操作呢?
更新
以防有人想要重现它,这里是过程:
- Create a new WinForms C# project.
Go to Form1's code and paste this in the constructor after the
InitializeComponent
line:DataGridView dgv = new DataGridView(); DataGridViewComboBoxColumn col1 = new DataGridViewComboBoxColumn(); DataGridViewComboBoxColumn col2 = new DataGridViewComboBoxColumn(); dgv.Columns.AddRange(new DataGridViewColumn[] { col1, col2 }); dgv.Dock = DockStyle.Fill; dgv.EditMode = DataGridViewEditMode.EditOnEnter; col1.Items.AddRange(new object[] { "Cat", "Dog", "Elephant", "Lion" }); col2.Items.AddRange(new object[] { "Duck", "Hen", "Crow", "Sparrow" }); this.Controls.Add(dgv);
Run the project. Click on the first drop-down, then click on the other dropdown without closing the first one. It will take 2 or 3 clicks (depending upon where you click in the second dropdown) to get the second list opened.
DataGridView
添加到你的表单中。添加两个DataGridViewComboBoxColumns
到其中,并放入一些项目。将EditMode
设置为EditOnEnter
,然后按下F5。 - dotNET