How to make a MessageBox pop up only if the value in ComboBox changes

Rusnnja

I'm trying to make the MessageBox pop up whenever the value in the combobox changes, instead, it currently pops up on the load and then when the value changes. Not sure what I'm doing wrong here.

Public Class DropDownBox

Private Sub DropDownBox_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    Dim dropSource As New Dictionary(Of String, String)()
    dropSource.Add("", "")
    dropSource.Add("1", "1")
    dropSource.Add("2", "2")
    dropSource.Add("3", "3")
    dropSource.Add("4", "4")
    dropSource.Add("5", "5")
    dropSource.Add("6", "6")
    dropSource.Add("7", "7")
    dropSource.Add("8", "8")
    dropSource.Add("9", "9")
    dropSource.Add("10", "10")

    cbox.DataSource = New BindingSource(dropSource, Nothing)
    cbox.DisplayMember = "Value"
    cbox.ValueMember = "Key"

    cbox.Text = Nothing

End Sub


Private Sub cbox_TextChanged(sender As Object, e As EventArgs) Handles cbox.TextChanged

    If cbox.Text IsNot Nothing Then
        MsgBox("Are you sure?")
    Else

    End If

End Sub

End Class

Thank you for your help.

Please let me know if you need any additional information on this subject, I've searched all over and haven't been able to figure this out.

Fabio

Event Combobox.SelectionChangeCommitted perfectly fit your requirement without extra workarounds.

The SelectionChangeCommitted event is raised only when the user changes the combo box selection

ComboBox.SelectionChangeCommitted Event

Private Sub cbox_SelectionChangeCommitted(sender As Object, e As EventArgs) 
                                                      Handles cbox.SelectionChangeCommitted

    Dim combobox = DirectCast(sender, ComboBox)
    If combobox.Text IsNot Nothing Then
        MsgBox("Are you sure?")
    End If

End Sub

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How to make linear layout inside pop up view responsive?

From Dev

How can I make the documentation pop-up on hover in PyCharm?

From Dev

How to make multiple JQuery pop up , on hyperlinks click?

From Dev

Xcode - How to make a pop up menu

From Dev

how to make pop up on left side of each icon in list view?

From Dev

how to make window.open pop up Modal?

From Dev

how to make pop-up image using css3?

From Dev

How would I make a message pop up after this form is submitted?

From Dev

How to replace javascript message pop-up to Jquery message pop-up with only ok button option

From Dev

How do is use the SetInterval function and the 'if' to make div's pop up?

From Dev

How to make a certain window pop up if a certain number is put in

From Dev

how to make an alert pop up before my script

From Dev

How to make new Office Communicator session pop up in Windows 7

From Dev

How can I make a Msgbox pop up over other application?

From Dev

how to make pop up on left side of each icon in list view?

From Dev

how to make a pop-up window using java

From Dev

How to call a html page and make it as pop up window in JavaScript?

From Dev

How can I make each word in a read-only textview touchable so that a pop-up appears when touched?

From Dev

How to make this pop up layer in the middle of the page?

From Dev

How to make a pop-up dialog that does not stop the program execution?

From Dev

How to replace javascript message pop-up to Jquery message pop-up with only ok button option

From Dev

How to make changes only for list that have sublist?

From Dev

How to make pop-up for error bootstrap?

From Dev

MessageBox with a comboBox inside and return the value of the comboBox

From Dev

How do I make a "div" element pop up and darken the screen?

From Dev

How to make a pop up button (Python)

From Dev

How to Make a Pop-Up Form's TextBox Required

From Dev

How to make my pop-up disappear after 3 sec

From Dev

VBA: How to pop up a messagebox when activecell.value having a division error

Related Related

  1. 1

    How to make linear layout inside pop up view responsive?

  2. 2

    How can I make the documentation pop-up on hover in PyCharm?

  3. 3

    How to make multiple JQuery pop up , on hyperlinks click?

  4. 4

    Xcode - How to make a pop up menu

  5. 5

    how to make pop up on left side of each icon in list view?

  6. 6

    how to make window.open pop up Modal?

  7. 7

    how to make pop-up image using css3?

  8. 8

    How would I make a message pop up after this form is submitted?

  9. 9

    How to replace javascript message pop-up to Jquery message pop-up with only ok button option

  10. 10

    How do is use the SetInterval function and the 'if' to make div's pop up?

  11. 11

    How to make a certain window pop up if a certain number is put in

  12. 12

    how to make an alert pop up before my script

  13. 13

    How to make new Office Communicator session pop up in Windows 7

  14. 14

    How can I make a Msgbox pop up over other application?

  15. 15

    how to make pop up on left side of each icon in list view?

  16. 16

    how to make a pop-up window using java

  17. 17

    How to call a html page and make it as pop up window in JavaScript?

  18. 18

    How can I make each word in a read-only textview touchable so that a pop-up appears when touched?

  19. 19

    How to make this pop up layer in the middle of the page?

  20. 20

    How to make a pop-up dialog that does not stop the program execution?

  21. 21

    How to replace javascript message pop-up to Jquery message pop-up with only ok button option

  22. 22

    How to make changes only for list that have sublist?

  23. 23

    How to make pop-up for error bootstrap?

  24. 24

    MessageBox with a comboBox inside and return the value of the comboBox

  25. 25

    How do I make a "div" element pop up and darken the screen?

  26. 26

    How to make a pop up button (Python)

  27. 27

    How to Make a Pop-Up Form's TextBox Required

  28. 28

    How to make my pop-up disappear after 3 sec

  29. 29

    VBA: How to pop up a messagebox when activecell.value having a division error

HotTag

Archive