帮助使移动文本正确 [英] Help on making the moving text go right

查看:86
本文介绍了帮助使移动文本正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好代码项目..



今天我需要一个移动标签的帮助。

i我试图让移动文本标签去虽然形状右手边的一端虽然左手边回来了。



我尝试了什么:



public string motd =;

MessageOTD.Left = this.Width;

MessageOTD.Text = motd;

/////////////////////////////////////// /////////////////////

i把它放在计时器里



MessageOTD.Left - = 1;

if(MessageOTD.Left + MessageOTD.Width< 0)

{

MessageOTD.Left = this 。宽;

}

//////////////////////////////// ///////////////////////////////

i把它放在表格上

this.MOTDTimer.Enabled = true;

this.MOTDTimer.Interval = 1;

this.MOTDTime r.Tick + = new System.EventHandler(this.MOTDTimer_Tick);

hello code project ..

today i need help with a moving label .
i am trying to make the moving text label go though one end of form "right hand side" and come back though the left hand side on a loop.

What I have tried:

public string motd = " ";
MessageOTD.Left = this.Width;
MessageOTD.Text = motd;
////////////////////////////////////////////////////////////
i put this inside a timer

MessageOTD.Left -= 1;
if (MessageOTD.Left + MessageOTD.Width < 0)
{
MessageOTD.Left = this.Width;
}
/////////////////////////////////////////////////////////////
i put this on form load
this.MOTDTimer.Enabled = true;
this.MOTDTimer.Interval = 1;
this.MOTDTimer.Tick += new System.EventHandler(this.MOTDTimer_Tick);

推荐答案

你在MessageOTD.Left上做了 - = 1。



如果是试图向右移动的标签(或类似物),请使用+ = 1.



Left属性是父容器左侧的像素数。



因此,如果Left == 15,则MessageOTD相对于父容器0向右15像素。



另外,你需要改变if块中的条件。



你应该要么检查Left是否等于Width(可能是Width - 1),

或做一个减法,Width - Left == 0
Your doing a -= 1 on the MessageOTD.Left.

If it is a label (or similar) trying to move right, use += 1.

The Left property is the number of pixels from the left side of the parent container.

So if Left == 15, then the MessageOTD is 15 pixels to the right, relative to parent container 0.

Also, you will need to change the condition in the if block.

You should either check that Left is equal to the Width (maybe Width - 1),
or do a subtraction, Width - Left == 0


谢谢你我会试试这个方法
thank you am gonna try this method


这篇关于帮助使移动文本正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆