Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7030959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:44:25+00:00 2026-05-28T00:44:25+00:00

I am having issues testing which icon my notifyIcon is using. I have a

  • 0

I am having issues testing which icon my notifyIcon is using.

I have a notifyicon instantiated for my program. When the program runs I assign an icon to it in my code.

public Form1()
    {            
        InitializeComponent();
        notifyIcon1.Icon = Properties.Resources.LogoIcon;
    }

I have 2 buttons, one which starts my timer, and 1 which stops my timer. The timer event is suppose to check which icon is currently being used and switch it to the other option, but it doesn’t work using my test.

Timer miniClock = new Timer();

    private void btnStartTimer_Click(object sender, EventArgs e)
    {           
        miniClock.Interval = 1000;
        miniClock.Tick += new EventHandler(MiniClockEventProcessor);
        miniClock.Start();
    }

    private void MiniClockEventProcessor(Object myObject, EventArgs myEventArgs)
    {
        if (notifyIcon1.Icon == Properties.Resources.AlertIcon)
        {
            notifyIcon1.Icon = Properties.Resources.LogoIcon;
        }
        else
            notifyIcon1.Icon = Properties.Resources.AlertIcon;

    }

    private void btnStopTimer_Click(object sender, EventArgs e)
    {
        miniClock.Stop();
        btnTest.Enabled = true;
    }

The frustrating part is when I start the timer, it will change the icon, but my test fails and it will only switch the icon in the else statement because there’s no criteria to it except that it fails the if statement? How can I test which icon is currently being used, and then switch the icon to it’s counterpart on the timer event call?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:44:25+00:00Added an answer on May 28, 2026 at 12:44 am

    I think it’s easier to relay on some state then to Icon itself.
    I imagine that yo setup AlertIcon or LogonIcon, based on some event, or on some changed state notification. It’s better to have somewhere the simple bool statevariable that indicates what happens.

    For example , to explain what am I talking about, is a pseudocode :

    private void MiniClockEventProcessor(Object myObject, EventArgs myEventArgs)
    {
       if (!IsAlertState)
       {
           notifyIcon1.Icon = Properties.Resources.LogoIcon;
       }
       else
           notifyIcon1.Icon = Properties.Resources.AlertIcon;
    
    }
    
    private bool IsAlertState {get;set}
    

    On recived alert the property IsAlertState = true.

    Something like this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having issues testing out the Scala Parser Combinator functionality for a simple
Im having issues getting this to work, maybe its not even possible? I have
I'm having issues with my SQL Reporting Services reports. I'm using a custom font
I'm having issues creating an ActionLink using Preview 5. All the docs I can
Having coded JavaScript since 1996, I have a very simple issue which I could
I've been having issues with testing my Grails application's authentication. It appears that the
I am testing a GNU Radio program which can tunnel TCP traffic over a
One of the developers in my team is having the following issues. They have
I'm testing out an app (hopefully to run on heroku, but am having issues
I'm having an small issue with SQLXML in SQL Server 2008. Here's my testing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.