用C#实现文字的来回滚动?

my_edxp 2008-11-21 01:13:06
我想用Lable在我的登陆窗体上把"图书馆"这几个字从左到右滚动!
...全文
655 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
mwx930317 2012-10-19
  • 打赏
  • 举报
回复
222
yangmaomao 2008-11-26
  • 打赏
  • 举报
回复
不是把。我试验不是你们说的哪么好。

private void timer1_Tick(object sender, EventArgs e)
{

if (label1.Left < this.Width)
{
label1.Left += 10;
}
else
{
label1.Left = 2;
}
}

这样可以保证来回滚动
hubofly 2008-11-23
  • 打赏
  • 举报
回复
就是由线程或者timer 不停的修改label的位置,就好,速度快点,就感觉在滚动了
lchh0917 2008-11-23
  • 打赏
  • 举报
回复
感觉是要生成来回滚动的效果的话,还是9楼正解
笺香 2008-11-23
  • 打赏
  • 举报
回复
学习学习呵
Deathsign 2008-11-22
  • 打赏
  • 举报
回复
private void Form1_Load(object sender, EventArgs e)
{
System.Windows.Forms.Timer t = new Timer();
t.Interval = 100;
t.Tick += new EventHandler(t_Tick);
t.Enabled = true;
}
bool rightMove=true;
void t_Tick(object sender, EventArgs e)
{
if (rightMove )
{
this.label1.Left += 10;
if(this.label1.Right >= this.Width-label1.Width)
{
rightMove =false;
}
}
else
{
this.label1.Left -= 10;
if(this.label1.Left <= label1.Width)
{
rightMove =true;
}


}
}
Deathsign 2008-11-22
  • 打赏
  • 举报
回复
private void Form1_Load(object sender, EventArgs e)
{
System.Windows.Forms.Timer t = new Timer();
t.Interval = 100;
t.Tick += new EventHandler(t_Tick);
t.Enabled = true;
}

void t_Tick(object sender, EventArgs e)
{
if (this.label1.Right < this.Width)
{
this.label1.Left += 10;

}
else
{
this.label1.Left -= 10;

}
System.Threading.Thread.Sleep(100);
Application.DoEvents();

}
net5i 2008-11-22
  • 打赏
  • 举报
回复
启动一个线程,线程内执行不断调整Label控件的Left属性的代码即可,同楼上各位同志
蝶恋花雨 2008-11-22
  • 打赏
  • 举报
回复
5.想要字体移动加这组代码:<marquee> </marquee>

(从右到左移动)

(从右到左移动)完整代码如下:

<marquee><P align=center><FONT face=宋体

color=#ff0000 size=5>我祝你练习成功 </FONT></P>

</marquee>

我祝你练习成功

想要字从左到右移动加:direction=right(从左到右移动)

(从左到右移动)完整代码如下:

<marquee direction=right><P align=center>

<FONT face=宋体 color=#ff0000 size=5>我祝你练习成功

</FONT></P></marquee>

我祝你练习成功

想要字向上移动加:direction=up(向上移动)

(向上移动)完整代码如下:

<marquee direction=up><P align=center>

<FONT face=宋体 color=#ff0000 size=5>我祝你练习成功

</FONT></P></marquee>

我祝你练习成功



想要字向下移动加:direction=down

(向下移动)完整代码如下:

<marquee direction=down><P align=center>

<FONT face=宋体 color=#ff0000 size=5>我祝你练习成功

</FONT></P></marquee>

我祝你练习成功

想要字左右来回移动代码:

<P align=center>
<MARQUEE scrollAmount=3 behavior=alternate

width="90%">
<STRONG><FONT size=5><FONT face=隶书 color=#b66222>

我祝你练习成功</FONT></FONT></STRONG></MARQUEE></P>

我祝你练习成功

scrollAmount=3这组数字是控制移动速度的,数字越大速度越快。

6.想要字在一定范围内移动加:width="90%" height=200 (width="90%")表示移动宽度,(height=200)表示高度范围,字体大就的高度数要大一点。
在加了这些属性后,可将代表把所有都放中间的代码移到最前面:<P align=center>
<P align=center><marquee width="90%" height=200><FONT face=宋体 color=#ff0000 size=5>我祝你练习成功</FONT></P></marquee>
如果觉得移动的速度不适合,就添加一个控制速度的代码在前一个移动代码的后面,代码是:scrollamount=n(移动速度数值),这个“n”是不定的,“1”最慢,数值越大就越快。
<marquee direction=right scrollamount=2>

示例代码如下:
<P align=center><marquee scrollamount=2 width="50%"

height=200><FONT face=宋体 color=#ff0000 size=5>

我祝你练习成功</FONT></P></marquee>
注意:
A、要用小于号"<"和大于号">"千万不要用《》
B、每添加一个属性代码,属性间都要空一格,
如:<marquee direction=right scrollamount=2>
不能这样:<marqueedirection=rightscrollamount=2>

蝶恋花雨 2008-11-22
  • 打赏
  • 举报
回复
marquee 不行吗?this.lbTitle.Text="<marquee >"+dt.rows[0]["title"].tostring+"</marquee >"
hangang7403 2008-11-22
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 jinjazz 的回复:]
C# code private void Form1_Load(object sender, EventArgs e)
{
System.Windows.Forms.Timer t = new Timer();
t.Interval = 100;
t.Tick += new EventHandler(t_Tick);
t.Enabled = true;
}

void t_Tick(object sender, EventArgs e)
{
if (this.label1.Right < this.Width)
{
this…
[/Quote]
1楼的 else
{
((Timer)sender).Enabled = false;
}
如果改成
else
{
this.lable1.Left=20(或其他位置);
}
就可以形成一个往复滚动效果了
shuangfeiwan 2008-11-22
  • 打赏
  • 举报
回复
不明白呵,学习学习
夜鹰 2008-11-22
  • 打赏
  • 举报
回复
由Windows移至C#
jinjazz 2008-11-21
  • 打赏
  • 举报
回复
  private void Form1_Load(object sender, EventArgs e)
{
System.Windows.Forms.Timer t = new Timer();
t.Interval = 100;
t.Tick += new EventHandler(t_Tick);
t.Enabled = true;
}

void t_Tick(object sender, EventArgs e)
{
if (this.label1.Right < this.Width)
{
this.label1.Left += 10;
System.Threading.Thread.Sleep(100);
Application.DoEvents();

}
else
{
((Timer)sender).Enabled = false;
}
}

111,130

社区成员

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

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

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