Search code examples
c#timestatusbartoolstripstatuslabel

ToolStripStatusLabel delay message


I have a brief question.

In my program I want to use a ToolStripStateLabel to display some info to the user. Comming from c++ and QT I don't quite understand the .net variant of this controll. Because I want to show the user a message for a certain ammount of time I.E 3000ms. or 3 seconds but I can't seem to figure out how to do this. So, is it even possible and, how do I do this?


Solution

  • Unfortunately you have to implement Timer to do that.

    private void InitTimer()
    {
      var myTimer = new Timer();
      myTimer.Tick += new EventHandler(TimerEventProcessor);
    
      // Sets the timer interval to 3 seconds.
      myTimer.Interval = 3000;
      myTimer.Start();
    }
    
    private static void TimerEventProcessor(object sender, EventArgs e)
    {
      ToolStripStatusLabel.Visible = false;
      (sender as Timer).Stop();
    }