如何手动下拉 DataGridViewComboBoxColumn? [英] How to manually drop down a DataGridViewComboBoxColumn?

查看:17
本文介绍了如何手动下拉 DataGridViewComboBoxColumn?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 WinForms 应用程序中有一个 DataGridView 和一个 DataGridViewComboBoxColumn.我需要手动下拉(打开)这个 DataGridViewComboBoxColumn,比如说在点击一个按钮之后.

I have a DataGridView with one DataGridViewComboBoxColumn in my WinForms application. I need to drop down (open) this DataGridViewComboBoxColumn manually, let's say after a button is clicked.

我需要这个的原因是我将 SelectionMode 设置为 FullRowSelect 并且我需要单击 2-3 次才能打开组合框.我想单击组合框单元格,它应该立即下拉.我想用 CellClick 事件来做到这一点,或者还有其他方法吗?

The reason I need this is I have set SelectionMode to FullRowSelect and I need to click 2-3 times to open the combo box. I want to click on the combobox cell and it should drop down immediately. I want to do this with CellClick event, or is there any other way?

我在 Google 和 VS 帮助中搜索,但我还没有找到任何信息.

I am searching in Google and VS help, but I haven't found any information yet.

有人可以帮忙吗?

推荐答案

我知道这不是理想的解决方案,但它确实创建了一个可在单元格内工作的单击组合框.

I know this can't be the ideal solution but it does create a single click combo box that works within the cell.

   Private Sub cell_Click(ByVal sender As System.Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView1.CellClick
        DataGridView1.BeginEdit(True)
        If DataGridView1.Rows(e.RowIndex).Cells(ddl.Name).Selected = True Then
            DirectCast(DataGridView1.EditingControl, DataGridViewComboBoxEditingControl).DroppedDown = True
        End If
    End Sub

其中ddl"是我在 gridview 中添加的组合框单元格.

where "ddl" is the combobox cell I added in the gridview.

这篇关于如何手动下拉 DataGridViewComboBoxColumn?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆