WinForm實(shí)現(xiàn)仿視頻播放器左下角滾動新聞效果的方法
更新時間:2015年08月22日 16:31:39 作者:我心依舊
這篇文章主要介紹了WinForm實(shí)現(xiàn)仿視頻播放器左下角滾動新聞效果的方法,涉及WinForm窗口滾動字幕設(shè)置的實(shí)現(xiàn)技巧,具有一定參考借鑒價值,需要的朋友可以參考下
本文實(shí)例講述了WinForm實(shí)現(xiàn)仿視頻播放器左下角滾動新聞效果的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
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; using System.Drawing.Imaging; using System.IO; using System.Xml.Linq; namespace App { public partial class Form7 : Form { private int Index { get; set; } private DataTable dataTable { get; set; } private System.Timers.Timer timer { get; set; } public Form7() { InitializeComponent(); dataTable = new DataTable(); dataTable.Columns.AddRange(new DataColumn[] { new DataColumn("Id",typeof(System.Int32)), new DataColumn("DisplayName",typeof(System.String)), new DataColumn("URL",typeof(System.String)) }); DataRow row = dataTable.NewRow(); row["Id"] = 1; row["DisplayName"] = "百度百科歡迎你!"; row["URL"] = "http://www.baidu.com"; dataTable.Rows.Add(row); row = dataTable.NewRow(); row["Id"] = 2; row["DisplayName"] = "劉XX明星已經(jīng)現(xiàn)身搜狐網(wǎng)站,趕快去圍觀!"; row["URL"] = "http://www.sohu.com"; dataTable.Rows.Add(row); row = dataTable.NewRow(); row["Id"] = 3; row["DisplayName"] = "新浪新聞出現(xiàn)重大新聞,點(diǎn)我快速查看!"; row["URL"] = "http://www.sina.com.cn"; dataTable.Rows.Add(row); row = dataTable.NewRow(); row["Id"] = 4; row["DisplayName"] = "網(wǎng)易客戶端出現(xiàn)新版本啦,趕快去體驗(yàn)把!"; row["URL"] = "http://www.126.com"; dataTable.Rows.Add(row); label1.Text = lblContent.Top.ToString(); timer = new System.Timers.Timer(2000); timer.Elapsed += delegate { CharsMouse(); }; timer.Start(); button1.Click += delegate { CharsMouse(); }; button2.Click += delegate { timer.Dispose(); }; lblContent.LinkClicked += delegate { label2.Text = dataTable.Rows[Index]["URL"].ToString(); }; } void CharsMouse() { this.lblContent.Invoke(new MethodInvoker(delegate { if (Index >= dataTable.Rows.Count) Index = 0; while (lblContent.Top > -lblContent.Height) { lblContent.Top = lblContent.Top - 2; label1.Text = "1.Top=" + lblContent.Top.ToString(); System.Threading.Thread.Sleep(100); Application.DoEvents(); } lblContent.Text = dataTable.Rows[Index]["DisplayName"].ToString(); lblContent.Top = 2; timer.Enabled = false; Application.DoEvents(); System.Threading.Thread.Sleep(2000); timer.Enabled = true; Index++; })); } } }
希望本文所述對大家的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)自定義右下角提示效果的方法
- C#實(shí)現(xiàn)winform漸變效果的方法
- WinForm實(shí)現(xiàn)同時讓兩個窗體有激活效果的特效實(shí)例
- C# WinForm實(shí)現(xiàn)Win7 Aero透明效果代碼
- winform下實(shí)現(xiàn)win7 Aero磨砂效果實(shí)現(xiàn)代碼
- 用 C# Winform做出全透明的磨砂玻璃窗體效果代碼
- WinForm實(shí)現(xiàn)狀態(tài)欄跑馬燈效果的方法示例
相關(guān)文章
桌面浮動窗口(類似惡意廣告)的實(shí)現(xiàn)詳解
本篇文章是對桌面浮動窗口的實(shí)現(xiàn)方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-06-06C# Dynamic關(guān)鍵字之:解析dynamic就是Object
本篇文章是對C#中dynamic關(guān)鍵字就是Object進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-05-05WCF實(shí)現(xiàn)進(jìn)程間管道通信Demo分享
下面小編就為大家分享一篇WCF實(shí)現(xiàn)進(jìn)程間管道通信Demo,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2017-12-12利用C#實(shí)現(xiàn)批量圖片格式轉(zhuǎn)換功能
這篇文章主要為大家詳細(xì)介紹了如何利用C#實(shí)現(xiàn)批量圖片格式轉(zhuǎn)換功能,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2022-12-12C#異步迭代IAsyncEnumerable應(yīng)用實(shí)現(xiàn)
IAsyncEnumerable可以來實(shí)現(xiàn)異步迭代,本文就主要介紹了C#異步迭代IAsyncEnumerable應(yīng)用實(shí)現(xiàn),具有一定的參考價值,感興趣的小伙伴們可以參考一下2021-06-06