none
怎么使DataGridViewComboBoxColumn的按钮点击一次后,就能出现下拉选项? RRS feed

  • 问题

  • DataGridViewComboBoxColumn的按钮点击后,不能出现下拉选项,而是先确定焦点,再次点击按钮才会出现下拉选项。
    怎么使DataGridViewComboBoxColumn的按钮点击一次后,就能出现下拉选项呢?

    2008年4月14日 5:22

答案

  •  feiyun0112 写:

     

    Code Snippet

    Me.DataGridView1.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter

     

     


    与客户想要的还有些差距,我在CellClick里面处理了一下

            If e.ColumnIndex >= 0 AndAlso e.RowIndex >= 0 AndAlso Me(e.ColumnIndex, e.RowIndex) IsNot Nothing _
                        AndAlso Not DataGridView1(e.ColumnIndex, e.RowIndex).ReadOnly Then
                Dim comboBoxColumn As DataGridViewComboBoxColumn = _
                                TryCast(DataGridView1.Columns(e.ColumnIndex), DataGridViewComboBoxColumn)
                If comboBoxColumn IsNot Nothing Then
                    Me.BeginEdit(False)
                    Dim comboBoxEditingControl As DataGridViewComboBoxEditingControl = _
                                TryCast(DataGridView1.EditingControl, DataGridViewComboBoxEditingControl)
                    If comboBoxEditingControl IsNot Nothing Then
                        comboBoxEditingControl.DroppedDown = True
                    End If

                End If
            End If
    2008年4月14日 6:15

全部回复

  •  

    Code Snippet

    Me.DataGridView1.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter

     

     

    2008年4月14日 6:08
    版主
  •  feiyun0112 写:

     

    Code Snippet

    Me.DataGridView1.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter

     

     


    与客户想要的还有些差距,我在CellClick里面处理了一下

            If e.ColumnIndex >= 0 AndAlso e.RowIndex >= 0 AndAlso Me(e.ColumnIndex, e.RowIndex) IsNot Nothing _
                        AndAlso Not DataGridView1(e.ColumnIndex, e.RowIndex).ReadOnly Then
                Dim comboBoxColumn As DataGridViewComboBoxColumn = _
                                TryCast(DataGridView1.Columns(e.ColumnIndex), DataGridViewComboBoxColumn)
                If comboBoxColumn IsNot Nothing Then
                    Me.BeginEdit(False)
                    Dim comboBoxEditingControl As DataGridViewComboBoxEditingControl = _
                                TryCast(DataGridView1.EditingControl, DataGridViewComboBoxEditingControl)
                    If comboBoxEditingControl IsNot Nothing Then
                        comboBoxEditingControl.DroppedDown = True
                    End If

                End If
            End If
    2008年4月14日 6:15