介绍
这篇文章将为大家详细讲解有关使用WinForm怎么实现一个状态栏跑马灯效果,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。
具体如下:
using 系统; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using 来; using 包含; using System.Windows.Forms; namespace WindowsFormsApplication1 { public 才能;partial  class Form1 :形式 {才能 ,,,public Form1 () ,,,{ ,,,,,InitializeComponent (); ,,,} ,,,private Label Label =, new 标签(); ,,,public string text =,“csdn baihe_591"; ,,,private void Form1_Load (object ,发送方,EventArgs e) ,,,{ ,,,,,this.label.Location =, new 点(149年,13); ,,,,,this.label.Size =, new 大小(134年,16); ,,,,,this.Controls.Add(标签); ,,,,,this.label.Text =,““ ,,,,,this.timer1.Enabled =,真的; ,,,,,this.timer1.Interval =, 500; ,,,,,p =, new PointF (this.label.Size.Width, 0); ,,,} ,,,PointF p; ,,,Font f =, new 字体(“宋体“,,10); ,,,Color c =, Color.White; ,,,string 温度; ,,,private void timer1_Tick (object ,发送方,EventArgs e) ,,,{ ,,,,,Graphics g =, this.label.CreateGraphics (); ,,,,,SizeF s =, new SizeF (); ,,,,,s =, g.MeasureString(文本,f);//测量文字长度 ,,,,,Brush Brush =, Brushes.Black; ,,,,,g.Clear (c);//清除背景 ,,,,,if (temp !=,文本)//文字改变时,重新显示 ,,,,,{ ,,,,,,,p =, new PointF (this.label.Size.Width, 0); ,,,,,,,temp =,文本; ,,,,,} ,,,,, ,,,,,,,p =, new PointF (p.X 安康;10日,0);//每次偏移10 ,,,,,if (p.X & lt;=, -s.Width) ,,,,,,,p =, new PointF (this.label.Size.Width, 0); ,,,,,g.DrawString(文本,f,刷,,p); ,,,} ,,} }
关于使用WinForm怎么实现一个状态栏跑马灯效果就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看的到。