winform怎么实现文字的上下滚动

xiaokaihuang 2007-09-03 10:14:27
winform怎么实现文字的上下滚动,就像电视台选秀节目中宣传短信发送方法那样的效果
...全文
561 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaokaihuang 2007-09-03
  • 打赏
  • 举报
回复
好的,谢谢,如果行,马上给分
北京的雾霾天 2007-09-03
  • 打赏
  • 举报
回复
参考一下这个代码:
public class ScrollWord:Form
{
private Rectangle m_WordRect;
private Timer timer;
public ScrollWord()
{
timer = new Timer();
timer.Interval = 100;
timer.Tick += new EventHandler(timer_Tick);
timer.Start();
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
this.timer.Dispose();
}
base.Dispose(disposing);
}
protected override void OnTextChanged(EventArgs e)
{
base.OnTextChanged(e);
Size size = TextRenderer.MeasureText(this.Text, this.Font);
this.m_WordRect = new Rectangle(this.m_WordRect.X, this.m_WordRect.Y, size.Width + 5, this.ClientRectangle.Height);
}
void timer_Tick(object sender, EventArgs e)
{
if (this.m_WordRect.Right < this.ClientRectangle.Left)
{
this.m_WordRect.X = this.ClientRectangle.Right;
}
else
{
this.m_WordRect.X--;
}
this.Invalidate();
}
protected override void OnPaint(PaintEventArgs e)
{
using (StringFormat format = new StringFormat())
{
format.LineAlignment = StringAlignment.Center;
format.Alignment = StringAlignment.Center;
e.Graphics.DrawString(this.Text, this.Font, SystemBrushes.ControlText, this.m_WordRect, format);
}
}
}
zhchg6666 2007-09-03
  • 打赏
  • 举报
回复
滚动可以算字符串
SkyAPI_COM 2007-09-03
  • 打赏
  • 举报
回复
在窗体上添加一个LABEL,启动一个线程,在线程中设置LABEL的TEXT属性~~
xiaokaihuang 2007-09-03
  • 打赏
  • 举报
回复
说详细些,最好有代码
lovefootball 2007-09-03
  • 打赏
  • 举报
回复
Timer+Graphics

110,535

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧