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
       
  • 相关阅读:
    Maximum Depth of Binary Tree
    Single Number
    Merge Two Sorted Lists
    Remove Nth Node From End of List
    Remove Element
    Remove Duplicates from Sorted List
    Add Two Numbers
    编译视频直播点播平台EasyDSS数据排序使用Go 语言 slice 类型排序的实现介绍
    RTMP协议视频直播点播平台EasyDSS在Linux系统中以服务启动报错can’t evaluate field RootPath in type*struct排查
    【解决方案】5G时代RTMP推流服务器/互联网直播点播平台EasyDSS实现360°全景摄像机VR直播
  • 原文地址:https://www.cnblogs.com/kting/p/2308866.html
Copyright © 2011-2022 走看看