请问怎么实现label上字符的平移效果? 就是如果字符到最左端后就自动从右端出来,一个跟着一个的,如果有其他办法也行可以不是label控件,只要能定位在界面上的某个指定位置就可以,谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 winform 还是 webform?如果是winform,使用timer控件很简单就能解决了,如果是webform,使用javascript,window.setInterval(函数,1000)也可以 是winform的,怎么使用timer,是一直去改变text的值吧?还请指教 楼主定义一个全局变量private bool bContinue = true;现大窗体内放入一个label1,一个button,在事件中加入GoAnimate();void GoAnimate() { while (bContinue) { if (this.label1.Left + this.label1.Width < 0) { this.label1.Left = this.Width ; } this.label1.Left -= 5; Application.DoEvents(); System.Threading.Thread.Sleep(100); } } 楼上这样做是移动label,这样做就不能实现前半部分字符出现在右端而后半部分字符出现在左端。继续请教 那就自己画了,drawstring,原理大同小异! 我有一个办法,就是用Timer和两个Label,两个Label的字符串是一样的,并且最好设成无边框,然后位置是连在一起,然后两个Label一起往一个方向移动(比如左),并且当某个Label移到a点的时候则跳到b点(b点要正好接到此时另一个Label的右边),接着一起向左移.如此反复.这样,字符串就有了一个跟一个的效果.为了出现只有一条字符串的效果,可以拉一些别的控件遮住左边控件的左一半和右边控件的又一半就好了(这些控件不要移动).具体的代码暂时没有时间写,但是楼主只要会用Timer和简单的循环就可以了.不知道这个想法楼主能不能接受.其实我一直就是认为写代码最重要的就是构思,新颖的想法,不知诸位是否认同. bluerush(我本行云) 说的是可以,但是我这边好象不能这么做,因为我是想在一个按扭上实现这个效果的 这样符合你的要求吗?Label1.Text = "<marquee direction=left behavior=SCROLL scrollamount=2 scrolldelay=10 scrollleft=0 scrolltop=0 id=nbagd height=20 width=100 onMouseOver=nbagd.stop() onMouseOut=nbagd.start()>随便</marquee>"; 是winform不是webform这个不行,要是行该多好哦! 用JS可以实现,你去网上可以搜索下,以前看到过用JS可以实现这种效果,不知道在LABLE上能不能实现 没有做过winform的,在webform中很好实现但是在winform 中就不知道了学习ing!! 给你个简单的,帮你搞定:首先定义一个数组: private System.Windows.Forms.Timer timer1; private System.Windows.Forms.Button button1; private string [] ab = new string [6]; static int num=0; private void Form1_Load(object sender, System.EventArgs e) { ab[0] = "啊 "; ab[1] = " 好啊"; ab[2] = "你好啊"; ab[3] = " 你好"; ab[4] = " 你"; ab[5] = " "; // Create a new Timer with Interval set to 10 seconds. System.Timers.Timer aTimer = new System.Timers.Timer(1000); aTimer.Elapsed+=new ElapsedEventHandler(move); aTimer.AutoReset = true; aTimer.Enabled = true; } private void move(object source, ElapsedEventArgs e) { this.button1.Text=ab[num++]; if(num==6) { num=0; } }其实就是用定时器调用这个move()就可以了。这可以达到你要的效果了吧,而且是在button上实现的效果:)!!! To Toti(as) 在winform的那些控件上可以使用JS脚本实现这个功能? 有其他知道这个吗? 基本上采用 bluerush(我本行云) 的方法,只不过把按扭改成panel,把两个label置在panel上! private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { this.label1.Left-=10; if(this.label1.Left<0) this.label2.Left-=10; if(this.label1.Left<=-this.label1.Width) { this.label1.Left=this.label2.Left; this.label2.Left=this.panel1.Width; } } vs2010 winform应用在windows7下无法创建测试证书 c#取整数的最后一位的函数是神马 winform 安全报错 弱弱的问一个类型转换的问题 弱弱的问一句。。c#中怎么添加DLL的引用 问个很简单的问题 请问如何实现在一个win form启动时自动按下一个按钮? 请教一个datagridview里checkbox的问题 急急!!!为什装不上iis??? 从数据库中取出的时间类型的数据怎样只取日期部分而不取时间部分? 如何使activex控件自动更新 如何解决发生“外部组件发生异常”这样的错误信息?
如果是winform,使用timer控件很简单就能解决了,
如果是webform,使用javascript,window.setInterval(函数,1000)也可以
还请指教
void GoAnimate()
{
while (bContinue)
{
if (this.label1.Left + this.label1.Width < 0)
{
this.label1.Left = this.Width ;
} this.label1.Left -= 5;
Application.DoEvents();
System.Threading.Thread.Sleep(100);
}
}
继续请教
Label1.Text = "<marquee direction=left behavior=SCROLL scrollamount=2 scrolldelay=10 scrollleft=0 scrolltop=0 id=nbagd height=20 width=100 onMouseOver=nbagd.stop() onMouseOut=nbagd.start()>随便</marquee>";
但是在winform 中就不知道了
学习ing!!
给你个简单的,帮你搞定:
首先定义一个数组:
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.Button button1;
private string [] ab = new string [6];
static int num=0;
private void Form1_Load(object sender, System.EventArgs e)
{
ab[0] = "啊 ";
ab[1] = " 好啊";
ab[2] = "你好啊";
ab[3] = " 你好";
ab[4] = " 你";
ab[5] = " ";
// Create a new Timer with Interval set to 10 seconds.
System.Timers.Timer aTimer = new System.Timers.Timer(1000);
aTimer.Elapsed+=new ElapsedEventHandler(move);
aTimer.AutoReset = true;
aTimer.Enabled = true;
}
private void move(object source, ElapsedEventArgs e)
{
this.button1.Text=ab[num++];
if(num==6)
{
num=0;
}
}
其实就是用定时器调用这个move()就可以了。
这可以达到你要的效果了吧,而且是在button上实现的效果:)!!!
有其他知道这个吗?
{
this.label1.Left-=10;
if(this.label1.Left<0)
this.label2.Left-=10;
if(this.label1.Left<=-this.label1.Width)
{
this.label1.Left=this.label2.Left;
this.label2.Left=this.panel1.Width;
}
}