网站首页
cms
asp
php
jsp
asp.net
数据库
web前端
服务器
javascript
c#
vb.net
java
linux
office
数据结构
其他语言
网络安全
电脑故障
电脑故障
位置:
IT落伍者
>>
电脑故障
>> 浏览文章
winform状态栏跑马灯的效果
发布日期:2022/7/11
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 WindowsFormsApplication
{public partial class Form
: Form{public Form
(){InitializeComponent();}private Label label = new Label();public string text = "csdn baihe_
";private void Form
_Load(object sender
EventArgs e){this
label
Location = new Point(
);this
label
Size = new Size(
);this
Controls
Add(label);this
label
Text = "";this
timer
Enabled = true;this
timer
Interval =
;p = new PointF(this
label
Size
Width
);}PointF p;Font f = new Font("宋体"
);Color c = Color
White;string temp;private void timer
_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
);temp = text;}elsep = new PointF(p
X
);//每次偏移
if (p
X <=
s
Width)p = new PointF(this
label
Size
Width
);g
DrawString(text
f
brush
p);}}}
上一篇:
获取url包括参数
下一篇:
rs.open和conn.execute