none
ComboBox2.SelectedIndexChanged问题 RRS feed

  • 问题

  • 有一个Datagridview1和一个combobox1

     Private Sub DataGridView1_SelectionChanged(sender As Object, e As EventArgs) Handles DataGridView1.SelectionChanged
         combobox1.text="a"
    end sub
    这个时候,能不引发ComboBox1.SelectedIndexChanged事件么?


    需要vbnet ,,,c#看不懂
    谢谢!
    • 已编辑 RF8862 2018年12月3日 1:32
    2018年12月3日 1:31

答案

  • Hi,

    你可以设置一个全局变量,让它去控制触发或者不触发。

    比如:

    Public Class Form1
        Dim tf As Boolean = True
        Private Sub DataGridView1_SelectionChanged(sender As Object, e As EventArgs) Handles DataGridView1.SelectionChanged
            ComboBox1.Text = "a"
            tf = False
        End Sub
        Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
            tf = True
            If tf = True Then
                MsgBox("123")
            End If
        End Sub
    End Class

    Best Regards,

    Alex



    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    • 已编辑 Alex-KSGZ 2018年12月4日 1:12
    • 已标记为答案 RF8862 2018年12月4日 11:13
    2018年12月3日 2:10