最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

WinForm實(shí)現(xiàn)狀態(tài)欄跑馬燈效果的方法示例

 更新時(shí)間:2017年07月06日 09:12:46   作者:a771948524  
這篇文章主要介紹了WinForm實(shí)現(xiàn)狀態(tài)欄跑馬燈效果的方法,涉及WinForm控件結(jié)合時(shí)間函數(shù)動(dòng)態(tài)操作元素屬性的相關(guān)技巧,需要的朋友可以參考下

本文實(shí)例講述了WinForm實(shí)現(xiàn)狀態(tài)欄跑馬燈效果的方法。分享給大家供大家參考,具體如下:

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);//測(cè)量文字長(zhǎng)度
      Brush brush = Brushes.Black;
      g.Clear(c);//清除背景
      if (temp != text)//文字改變時(shí),重新顯示
      {
        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);
    }
  }
}

更多關(guān)于C#相關(guān)內(nèi)容感興趣的讀者可查看本站專(zhuān)題:《WinForm控件用法總結(jié)》、《C#窗體操作技巧匯總》、《C#數(shù)據(jù)結(jié)構(gòu)與算法教程》、《C#常見(jiàn)控件用法教程》、《C#面向?qū)ο蟪绦蛟O(shè)計(jì)入門(mén)教程》及《C#程序設(shè)計(jì)之線(xiàn)程使用技巧總結(jié)

希望本文所述對(duì)大家C#程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論

西乌| 来凤县| 哈尔滨市| 平湖市| 永德县| 万山特区| 荥经县| 京山县| 濉溪县| 克山县| 辛集市| 涿州市| 甘肃省| 连江县| 宁武县| 华蓥市| 黑河市| 贺兰县| 兴宁市| 行唐县| 应城市| 东乡族自治县| 新泰市| 伽师县| 贵港市| 乌拉特后旗| 革吉县| 大余县| 拜城县| 辉南县| 隆子县| 深泽县| 岳西县| 忻城县| 托克逊县| 武义县| 红安县| 南丹县| 华亭县| 乐亭县| 乡宁县|