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
       
  • 相关阅读:
    BERT 简介 P1_李宏毅
    GAN_P4 Learning from Unpaired Data_李宏毅
    GAN_P3_李宏毅
    Generation P1_李宏毅
    GAN_P2_Theory behind GAN_李宏毅
    李宏毅_Transformer p2
    李宏毅_Transformer p1
    强类型数据集 官方教程
    网页管理系统一
    读张子阳的用户验证自定义IPrincipal和IIdentity有感
  • 原文地址:https://www.cnblogs.com/kting/p/2308866.html
Copyright © 2011-2022 走看看