Results 1 to 3 of 3

Thread: Having problem with dropdownbutton...

  1. #1

    Thread Starter
    Hyperactive Member Pac_741's Avatar
    Join Date
    Jun 2007
    Location
    Mexico
    Posts
    298

    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

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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:
    1. 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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Hyperactive Member Pac_741's Avatar
    Join Date
    Jun 2007
    Location
    Mexico
    Posts
    298

    Re: Having problem with dropdownbutton...

    thanks man...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width