datagridview(VB.NET)中的datagridviewcombobox列 [英] datagridviewcombobox column in datagridview (VB.NET)

查看:508
本文介绍了datagridview(VB.NET)中的datagridviewcombobox列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在datagrid(vb.net)中使用了inbuild datagridviewcombobox列.我要使该单元格的组合框DropDownstyle在特定单元格获得焦点时下拉.

I have used inbuild datagridviewcombobox column in datagrid (vb.net). I want to make that cell''s combobox DropDownstyle to dropdown, when that particular cell gets the focus.

推荐答案



在您的表单中插入一个datagridview并将其命名为"MyDataGridView".

要在DataGridView中添加d​​atagridviewcombobox列,请在设计窗口中右键单击datagridview并选择属性.

然后查找属性列".然后单击"..."按钮.单击添加按钮以添加列...



将以下代码放在您的代码窗口中,以在聚焦时激活Combobox自动下拉菜单...



Hi,

Insert a datagridview in your form and name it "MyDataGridView".

To Add datagridviewcomboboxcolumns in your DataGridView, right click your datagridview in design window and select properties.

Then look for property "Columns". Then click the "..." button. Click Add button to add Columns...



Put the following code in your code window, to activate Combobox auto dropdown when focus ...



Private Sub MyDataGridView_CellEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles MyDataGridView.CellEnter
    ''# Code to Dropdown DataGridViewComboBox in single click
    ''Header Cell clicked -> ignore it.
    If (e.RowIndex = -1) Then
        Return
    End If


    MyDataGridView.BeginEdit(True)
    If TypeOf MyDataGridView.EditingControl Is DataGridViewComboBoxEditingControl Then
        Dim control As DataGridViewComboBoxEditingControl = MyDataGridView.EditingControl
        If Not IsNothing(control) Then
            control.DroppedDown = True
        End If
    End If
  '#End of Code to Dropdown DataGridViewComboBox 

End Sub






-----------
问候,
B.LAKSHMI NARAYANAN
使用解决方案
图替林
+919940292099
www.usesolutions.net
usesolutions@yahoo.com






-----------
Regards,
B.LAKSHMI NARAYANAN
USE SOLUTIONS
TUTICORIN
+919940292099
www.usesolutions.net
usesolutions@yahoo.com


这篇关于datagridview(VB.NET)中的datagridviewcombobox列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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