WinForm实现状态栏跑马灯效果的方法示例
作者:a771948524 时间:2023-07-16 19:37:33
本文实例讲述了WinForm实现状态栏跑马灯效果的方法。分享给大家供大家参考,具体如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
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)
{
this.label.Location = new Point(149, 13);
this.label.Size = new Size(134, 16);
this.Controls.Add(label);
this.label.Text = "";
this.timer1.Enabled = true;
this.timer1.Interval = 500;
p = new PointF(this.label.Size.Width, 0);
}
PointF p;
Font f = new Font("宋体", 10);
Color c = Color.White;
string temp;
private void timer1_Tick(object sender, EventArgs e)
{
Graphics g = this.label.CreateGraphics();
SizeF s = new SizeF();
s = g.MeasureString(text, f);//测量文字长度
Brush brush = Brushes.Black;
g.Clear(c);//清除背景
if (temp != text)//文字改变时,重新显示
{
p = new PointF(this.label.Size.Width, 0);
temp = text;
}
else
p = new PointF(p.X - 10, 0);//每次偏移10
if (p.X <= -s.Width)
p = new PointF(this.label.Size.Width, 0);
g.DrawString(text, f, brush, p);
}
}
}
希望本文所述对大家C#程序设计有所帮助。
标签:WinForm,状态栏
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
JAVA实现扫描线算法(超详细)
2023-06-30 13:33:20
![](https://img.aspxhome.com/file/2023/3/78333_0s.jpg)
Android如何从实现到封装一个MVP详解
2023-02-12 10:44:40
![](https://img.aspxhome.com/file/2023/5/138775_0s.png)
SWT(JFace)体验之复制粘贴
2022-11-18 13:47:46
详解Android封装一个全局的BaseActivity
2022-09-16 07:05:23
C#中的委托使用
2021-08-12 09:36:57
Android 连接蓝牙扫码器无输入框的实现
2023-05-06 02:37:34
springmvc和js前端的数据传递和接收方式(两种)
2021-06-15 08:33:37
Java Web实现添加定时任务的方法示例
2023-11-25 02:12:15
java 实现MD5加密算法的简单实例
2023-07-19 21:53:56
Kotlin LinearLayout与RelativeLayout布局使用详解
2021-12-06 02:07:30
![](https://img.aspxhome.com/file/2023/8/137998_0s.png)
C#调用CMD命令实例
2021-06-17 10:08:12
Android手机开发设计之记事本功能
2023-12-10 21:47:00
![](https://img.aspxhome.com/file/2023/2/138102_0s.jpg)
Java判断主机是否能ping通代码实例
2023-04-26 22:18:27
![](https://img.aspxhome.com/file/2023/8/90958_0s.png)
Android下拉列表spinner的实例代码
2023-07-31 20:39:47
![](https://img.aspxhome.com/file/2023/2/86012_0s.jpg)
C#写入XML文档
2022-03-21 18:08:33
Java内存模型final的内存语义
2023-06-05 08:02:25
![](https://img.aspxhome.com/file/2023/0/62130_0s.png)
基于Spring整合mybatis注解扫描是否成功的问题
2023-01-23 18:29:22
![](https://img.aspxhome.com/file/2023/9/71149_0s.png)
java代码实现C盘文件统计工具
2021-06-23 01:22:38
![](https://img.aspxhome.com/file/2023/4/67664_0s.png)
Java中mybatis的三种分页方式
2021-06-25 11:14:05
![](https://img.aspxhome.com/file/2023/7/67607_0s.png)
深入理解Android热修复技术原理之so库热修复技术
2023-11-19 15:02:10
![](https://img.aspxhome.com/file/2023/8/137178_0s.jpg)