-
Jan 25th, 2017, 10:24 AM
#1
Thread Starter
Lively Member
[RESOLVED] Message Box
I am trying to program a message box on when someone clicks into a combobox. I tried this and I am getting a continuous message box. How do I only show it one time, before they select an item in the combobox?
Code:
Private Sub cboInteriorCarvassSpecie_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboInteriorCarcassSpecie.Click
Dim msg = "Test Message"
Dim Title = "Information"
Dim Style = MsgBoxStyle.OkOnly
MsgBox(msg, Style, Title)
End Sub
TIA
Jeff
-
Jan 25th, 2017, 10:36 AM
#2
Re: Message Box
by "continuous" ... do you mean you get an endless loop of messageboxes? or that you keep getting it every time you click the cbo?
-tg
-
Jan 25th, 2017, 10:38 AM
#3
Thread Starter
Lively Member
Re: Message Box
Originally Posted by techgnome
by "continuous" ... do you mean you get an endless loop of messageboxes? or that you keep getting it every time you click the cbo?
-tg
I keep getting the message box each time I click the cbo.
JM
-
Jan 25th, 2017, 10:43 AM
#4
Re: Message Box
That is to be expected, because you have put the code in the _Click event of the combo... which fires every time you click.
If you only want something to happen when it gets the focus, use an event dedicated to that purpose.
-
Jan 25th, 2017, 10:46 AM
#5
Thread Starter
Lively Member
Re: Message Box
Originally Posted by si_the_geek
That is to be expected, because you have put the code in the _Click event of the combo... which fires every time you click.
If you only want something to happen when it gets the focus, use an event dedicated to that purpose.
That is the issue, what event should I use?
-
Jan 25th, 2017, 10:57 AM
#6
Re: Message Box
The click could work, but you need to track a flag somehow and set it when you show it, so that when you come back around, if it's set you don't show the message.
That said... I'm not sure I like having messageboxes pop up when I click a combo box... it takes the focus away, and then I still have to click the CBo again. Doesn't feel like a good user experience to me.
-tg
-
Jan 25th, 2017, 11:02 AM
#7
Thread Starter
Lively Member
Re: Message Box
Originally Posted by techgnome
The click could work, but you need to track a flag somehow and set it when you show it, so that when you come back around, if it's set you don't show the message.
That said... I'm not sure I like having messageboxes pop up when I click a combo box... it takes the focus away, and then I still have to click the CBo again. Doesn't feel like a good user experience to me.
-tg
I agree on the user experience thing, I am building this for another company and the owner of the company wants a messagebox, me personally, I hate using them. Just adds extra clicks.
This being said, is there another option for this? Before, I had the information off to the right in a label which was there from the start of the form load.
JM
-
Jan 25th, 2017, 11:22 AM
#8
Re: Message Box
*shrug* I don't know the situation... only the code you posted, which appears to be sample code to illustrate the problem. The answer of how I'd implement it would depend on the situation and what it is exactly you're trying to show.
-tg
-
Jan 25th, 2017, 11:31 AM
#9
Re: Message Box
Originally Posted by jmyersnc
That is the issue, what event should I use?
A quick look at the list of events for a combobox:
https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx
...shows that it has GotFocus ("Occurs when the control receives focus")
-
Jan 25th, 2017, 11:50 AM
#10
Re: Message Box
You might want to quietly add some Ctrl+key combination on the form such that whatever solution you come up with can be turned on/off. I can totally see the person who wants this coming back with, "this is SO annoying. Make it stop!" So, you might handle keypress events at the form level and add one to turn off displaying the messagebox.
My usual boring signature: Nothing
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|