WinForm實(shí)現(xiàn)狀態(tài)欄跑馬燈效果的方法示例
本文實(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);//測量文字長度 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)容感興趣的讀者可查看本站專題:《WinForm控件用法總結(jié)》、《C#窗體操作技巧匯總》、《C#數(shù)據(jù)結(jié)構(gòu)與算法教程》、《C#常見控件用法教程》、《C#面向?qū)ο蟪绦蛟O(shè)計(jì)入門教程》及《C#程序設(shè)計(jì)之線程使用技巧總結(jié)》
希望本文所述對大家C#程序設(shè)計(jì)有所幫助。
- WinForm實(shí)現(xiàn)窗體最大化并遮蓋任務(wù)欄的方法
- C#實(shí)現(xiàn)WinForm禁止最大化、最小化、雙擊標(biāo)題欄、雙擊圖標(biāo)等操作的方法
- Winform實(shí)現(xiàn)鼠標(biāo)可穿透的窗體鏤空效果
- Winform窗體效果實(shí)例分析
- WinForm實(shí)現(xiàn)自定義右下角提示效果的方法
- WinForm實(shí)現(xiàn)仿視頻播放器左下角滾動新聞效果的方法
- C#實(shí)現(xiàn)winform漸變效果的方法
- WinForm實(shí)現(xiàn)同時(shí)讓兩個窗體有激活效果的特效實(shí)例
- C# WinForm實(shí)現(xiàn)Win7 Aero透明效果代碼
- winform下實(shí)現(xiàn)win7 Aero磨砂效果實(shí)現(xiàn)代碼
- 用 C# Winform做出全透明的磨砂玻璃窗體效果代碼
相關(guān)文章
10個C#程序員經(jīng)常用到的實(shí)用代碼片段
如果你是一個C#程序員,那么本文介紹的10個C#常用代碼片段一定會給你帶來幫助,從底層的資源操作,到上層的UI應(yīng)用,這些代碼也許能給你的開發(fā)節(jié)省不少時(shí)間。以下是原文:2015-09-09Unity游戲開發(fā)之射擊小游戲的實(shí)現(xiàn)
本篇文章為大家?guī)硪粋€橫版2D射擊小游戲,游戲制作超級簡單,玩法一學(xué)就會。文中的示例代碼講解詳細(xì),快跟隨小編一起動手試一試2022-03-03C#自定義的方法實(shí)現(xiàn)堆棧類設(shè)計(jì)
這篇文章主要為大家詳細(xì)介紹了如何使用C#創(chuàng)建一個帶有Push方法和Clist類的CStack類,并如何在其中添加和遍歷堆棧數(shù)據(jù),感興趣的可以了解下2024-03-03