|
-
Sep 21st, 2007, 09:40 PM
#1
Thread Starter
Hyperactive Member
Having problem with dropdownbutton...
I am using this code to change a textbox text but nothing happens i am using it in textbox lost focus event ..
If Me.ToolStripDropDownButton1.Image Is My.Resources.ask_icon Then
Me.ToolStripTextBox1.Text = "Search ask"
ElseIf Me.ToolStripDropDownButton1.Image Is My.Resources.YahooIcon Then
Me.ToolStripTextBox1.Text = "Search yahoo"
ElseIf Me.ToolStripDropDownButton1.Image Is My.Resources.google_54 Then
Me.ToolStripTextBox1.Text = "Search google"
End If
-
Sep 21st, 2007, 10:13 PM
#2
Re: Having problem with dropdownbutton...
Firstly, you shouldn't be using the LostFocus event at all. To do something when the focus leaves a control you handle the Leave event.
Secondly, your problem is that every time you access a property from My.Resources it creates a new object. No existing object can possibly be that object so your comparisons will always evaluate to False. Even this would evaluate to False:
vb.net Code:
My.Resources.ask_icon Is My.Resources.ask_icon
because it is testing whether two different objects are the same object. You need to retrieve your resources once and once only. You can assign them to member variables then access them from there. That way there will be one instance only of each one, so your comparisons will evaluate to True.
-
Sep 22nd, 2007, 03:44 PM
#3
Thread Starter
Hyperactive Member
Re: Having problem with dropdownbutton...
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
|