vb combobox 中的selectedindexchanged 事件
combobox再触发selectedindexchanged 事件时,判断messagebox的结果,当选择yes时,才改变selectedindex
我vb6 combobox 中没 selectedindexchanged 事件
你是哪版的VB?
Option Explicit ' 是否第一次改变. Dim blnFirstChanged As Boolean ' 是否跳过单击事件. Dim blnJumpClickEvent As Boolean ' ComboBox 下拉列表改变之前的索引号. Dim intListIndexBeforeChanging As Integer Private Sub Combo1_Click() ' /* 如果第一次改变. */ If blnFirstChanged Then blnFirstChanged = False Exit Sub Else If blnJumpClickEvent Then blnJumpClickEvent = False Exit Sub Else If MsgBox("是否改变下拉列表框的索引?", vbQuestion + vbYesNo) = vbNo Then blnJumpClickEvent = True Combo1.ListIndex = intListIndexBeforeChanging Else ' 改变后的下拉列表索引号就是下一次改变之前的索引号. intListIndexBeforeChanging = Combo1.ListIndex End If End If End If End Sub Private Sub Form_Load() ' /* 添加测试数据. */ With Combo1 .AddItem "MBC" .AddItem "KBS" .AddItem "SBS" .AddItem "TJB" ' 防止第一次改变时触发 ComboBox 的 Click 事件. blnFirstChanged = True .ListIndex = 0 intListIndexBeforeChanging = .ListIndex blnJumpClickEvent = False End With End Sub