WinForm实现仿视频播放器左下角滚动新闻效果的方法
程序员文章站
2023-01-10 16:55:38
本文实例讲述了winform实现仿视频播放器左下角滚动新闻效果的方法。分享给大家供大家参考。具体实现方法如下:
using system;
using syst...
本文实例讲述了winform实现仿视频播放器左下角滚动新闻效果的方法。分享给大家供大家参考。具体实现方法如下:
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明星已经现身搜狐网站,赶快去围观!"; row["url"] = "http://www.sohu.com"; datatable.rows.add(row); row = datatable.newrow(); row["id"] = 3; row["displayname"] = "新浪新闻出现重大新闻,点我快速查看!"; row["url"] = "http://www.sina.com.cn"; datatable.rows.add(row); row = datatable.newrow(); row["id"] = 4; row["displayname"] = "网易客户端出现新版本啦,赶快去体验把!"; 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#程序设计有所帮助。
上一篇: 蕨菜怎么拌好吃又营养价值高
下一篇: C#实现清空回收站的方法