zoukankan      html  css  js  c++  java
  • DataGridViewComboBoxColumn multiple click SelectedIndexChanged event

    1.DataGridView中的comboBox需要点击2次或多次才能弹出下拉item

    first:

    Me.DataGridView1.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter
    second:
    If e.ColumnIndex >= 0 AndAlso e.RowIndex >= 0 AndAlso DataGridView1(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               

          DataGridView1.BeginEdit(False)
                    Dim comboBoxEditingControl As DataGridViewComboBoxEditingControl = _
                                TryCast(DataGridView1.EditingControl, DataGridViewComboBoxEditingControl)
                    If comboBoxEditingControl IsNot Nothing Then
                        comboBoxEditingControl.DroppedDown = True
                    End If

                End If
            End If

    2.向DataGridView中的comboBox添加SelectedIndexChanged后多次触发
    Private Sub dgvBudgetDetail_EditingControlShowing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles dgvBudgetDetail.EditingControlShowing
            If dgvBudgetDetail.CurrentCell.ColumnIndex = 11 Then
                Dim combo As ComboBox = CType(e.Control, ComboBox)
                If (combo IsNot Nothing) Then

                    ' Remove an existing event-handler, if present, to avoid
                    ' adding multiple handlers when the editing control is reused.
                    RemoveHandler combo.TextChanged,  New EventHandler(AddressOf ComboBox_SelectedIndexChanged)

                    ' Add the event handler.
                    AddHandler combo.TextChanged,   New EventHandler(AddressOf ComboBox_SelectedIndexChanged)

                End If
            End If
        End Sub
    Private Sub ComboBox_SelectedIndexChanged(  ByVal sender As Object, ByVal e As EventArgs)
            Dim jj As Integer = dgvBudgetDetail.CurrentRow.Index
            Dim comboBox1 As ComboBox = CType(sender, ComboBox)

            If CType(sender, ComboBox).SelectedItem IsNot Nothing Then
             
     
            Else
                RemoveHandler comboBox1.TextChanged, _
                          New EventHandler(AddressOf ComboBox_SelectedIndexChanged)
            End If

        End Sub
       
  • 相关阅读:
    aul 学习测试(测量)
    ubuntu12.04下一个samba、tftp、nfs构造
    Linux互斥和同步应用程序(一):posix线程和线程之间的相互排斥
    Cocos2d-x加速度计
    事务处理和并发控制
    【通过做专题研习Android】知识点:SharedPreferences
    数据结构 --- 单人名单
    安德鲁斯 建立与各种听众自己定义的ScrollView
    【iOS开展-94】xcode6如何使用GIT以及如何添加太老项目GIT特征?
    2013年第35周一
  • 原文地址:https://www.cnblogs.com/kting/p/2308866.html
Copyright © 2011-2022 走看看