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

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

问题描述

我有我的WinForms应用的一个DataGridViewComboBoxColumn一个DataGridView。我需要手动下拉(开放)这个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?

我搜索在谷歌和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天全站免登陆