首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

toolStripStatusLabel里面的文字滚动,该怎么处理

2012-04-26 
toolStripStatusLabel里面的文字滚动winform中statusStrip1中怎样让某一个toolStripStatusLabel里面的文字

toolStripStatusLabel里面的文字滚动
winform中statusStrip1中怎样让某一个toolStripStatusLabel里面的文字滚动。。。

[解决办法]
Lable的绘制事件,timer来实现
1.订阅Lable的绘制事件 
void label1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) 

Label lb = sender as Label; 
e.Graphics.DrawString(lb.Text,lb.Font,Brushes.Black,new PointF(paintX,0)); 

2.设置一个Timer定时重绘Lable控制 
void timer_Tick(object sender, EventArgs e) 

paintX = (++ paintX) % label1.Width; 
label1.Invalidate(); 
}

其他的参考:http://blog.163.com/zhangxinxiao_zxx/blog/static/1119762152009728920257/
[解决办法]

C# code
        string s = "中华人民共和国中华人民共和国";        int i = 0;        private void timer1_Tick(object sender, EventArgs e)        {            SetText(i);            i++;        }        private void SetText(int index)        {//记得添加容错,放置 i 越界            toolStripStatusLabel1.Text = s.Substring(i, s.Length - i);        } 

热点排行