SoFunction
Updated on 2025-03-06

Example of method for WinForm to implement the status bar marquee effect

This article describes the method of WinForm to implement the status bar marquee effect. Share it for your reference, as follows:

using System;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
namespace WindowsFormsApplication1
{
  public partial class Form1 : Form
  {
    public Form1()
    {
      InitializeComponent();
    }
    private Label label = new Label();
    public string text = "csdn baihe_591";
    private void Form1_Load(object sender, EventArgs e)
    {
       = new Point(149, 13);
       = new Size(134, 16);
      (label);
       = "";
      this. = true;
      this. = 500;
      p = new PointF(, 0);
    }
    PointF p;
    Font f = new Font("Song-style", 10);
    Color c = ;
    string temp;
    private void timer1_Tick(object sender, EventArgs e)
    {
      Graphics g = ();
      SizeF s = new SizeF();
      s = (text, f);//Measure text length      Brush brush = ;
      (c);//Clear the background      if (temp != text)//Redisplay again when the text changes      {
        p = new PointF(, 0);
        temp = text;
      }
      else
        p = new PointF( - 10, 0);//Only offset 10      if ( <= -)
        p = new PointF(, 0);
      (text, f, brush, p);
    }
  }
}

For more information about C# related content, please check out the topic of this site:Summary of WinForm control usage》、《Summary of C# form operation skills》、《C# data structure and algorithm tutorial》、《Tutorial on the usage of common C# controls》、《Introduction to C# object-oriented programming tutorial"and"Summary of thread usage techniques for C# programming

I hope this article will be helpful to everyone's C# programming.