小弟现在想做一个关于label从下往上移动的窗体。基本功能已实现,但效果不理想,不理想在哪呢?在一段文字走完了以后,会出现一屏的空白。望大侠们赐教下!!!基本代码如下:
int loc_text = 0;
private void timer1_Tick(object sender, EventArgs e)
{
int FWidth = this.panel1.Width;
int FHeight = this.panel1.Height; Point LPos = new Point(this.label1.Location.X, this.label1.Location.Y);
if (LPos.Y < FHeight)
{
if (LPos.Y < -loc_text)
{
this.label1.Location = new Point(0, this.Height - 72); return;
} this.label1.Location = new Point(LPos.X, LPos.Y - 10);
return;
}
else
{
this.label1.Location = new Point(0, 0);
}
}
private void JCZ_SendNews_Load(object sender, EventArgs e)
{
this.label1.Location = new Point(0, this.Height - 72);
label1.Text = " 紧急通知\n由于近期物价高涨,燃油价格也高涨,反正就是什么都贵了。为了体现中国加入WTO与国际接轨的精神,本店铺也将提价10%,表示对国家的物质文明建设的贡献!"; int sumChar = label1.Text.Length;
int rowCount = (sumChar / 10) + 1;
label1.Height = rowCount * 100;
loc_text = rowCount * 100;
label1.Size = new Size(1024, label1.Height);
label1.Font = new Font("黑体", 72);
label1.ForeColor = Color.Red;
this.BackColor = Color.Black; this.timer1.Enabled = true;
this.timer1.Interval = 300;
this.timer1.Start(); }
窗体的尺寸为:1024,768winformlabel从下往上移动timer
int loc_text = 0;
private void timer1_Tick(object sender, EventArgs e)
{
int FWidth = this.panel1.Width;
int FHeight = this.panel1.Height; Point LPos = new Point(this.label1.Location.X, this.label1.Location.Y);
if (LPos.Y < FHeight)
{
if (LPos.Y < -loc_text)
{
this.label1.Location = new Point(0, this.Height - 72); return;
} this.label1.Location = new Point(LPos.X, LPos.Y - 10);
return;
}
else
{
this.label1.Location = new Point(0, 0);
}
}
private void JCZ_SendNews_Load(object sender, EventArgs e)
{
this.label1.Location = new Point(0, this.Height - 72);
label1.Text = " 紧急通知\n由于近期物价高涨,燃油价格也高涨,反正就是什么都贵了。为了体现中国加入WTO与国际接轨的精神,本店铺也将提价10%,表示对国家的物质文明建设的贡献!"; int sumChar = label1.Text.Length;
int rowCount = (sumChar / 10) + 1;
label1.Height = rowCount * 100;
loc_text = rowCount * 100;
label1.Size = new Size(1024, label1.Height);
label1.Font = new Font("黑体", 72);
label1.ForeColor = Color.Red;
this.BackColor = Color.Black; this.timer1.Enabled = true;
this.timer1.Interval = 300;
this.timer1.Start(); }
窗体的尺寸为:1024,768winformlabel从下往上移动timer
解决方案 »
- c#中日期格式为什么不对呢?
- checkbox如何将多个选入textbox?
- 由一个GroupBox控件里面放置一个TextBox、一个ComboBox、一个RadioButton,如何将这四个控件制作成一个控件添加到vs中当作一个控件使用。
- 重金奖---解决如下问题者
- 请问"退出本人做的电子商务网站“怎么编码
- 分都给光了。唉 问个问题缩略图生成。。!!
- C#画图软件中如何在FORM上可画图的同时,在左侧PANEL也可画图?
- C#编写简单的聊天程序
- 网站(mvc)浏览器兼容问题
- C#作的程序能在win98上运行吗?
- 微信自动回复,不知道哪个高手做过,回复语句数据库该怎么设计。有没有现成的解决方案。
- Ui Automation自动化测试取变化窗体名称对应的句柄的问题
=>
if (LPos.Y+label1.Height < FHeight)
你用一个线程做。那个不会停顿的。
if (LPos.Y < -loc_text)判断不对,应该是
if (LPos.Y < -label1.Height) private void timer1_Tick(object sender, EventArgs e)
{
int FWidth = this.panel1.Width;
int FHeight = this.panel1.Height; Point LPos = this.label1.Location;
if (LPos.Y < FHeight)
{
if (LPos.Y < -label1.Height)
{
this.label1.Location = new Point(0, this.Height - 72);
return;
} this.label1.Location = new Point(LPos.X, LPos.Y - 10);
}
else
{
this.label1.Location = new Point(0, 0);
}
}
private void JCZ_SendNews_Load(object sender, EventArgs e)
{
this.label1.Location = new Point(0, this.Height - 72);
label1.Text = " 紧急通知\n由于近期物价高涨,燃油价格也高涨,反正就是什么都贵了。为了体现中国加入WTO与国际接轨的精神,本店铺也将提价10%,表示对国家的物质文明建设的贡献!"; int sumChar = label1.Text.Length;
int rowCount = (sumChar / 10) + 1;
label1.Height = rowCount * 100;
label1.Size = new Size(1024, label1.Height);
label1.Font = new Font("黑体", 72);
label1.ForeColor = Color.Red;
//this.BackColor = Color.Black;
this.timer1.Enabled = true;
this.timer1.Interval = 300;
this.timer1.Start(); }
Label label2 = new Label();
bool Bo = true;
bool Bol = true;
private void timer1_Tick(object sender, EventArgs e)
{
int FWidth = this.panel1.Width;
int FHeight = this.panel1.Height; Point LPos = new Point(this.label1.Location.X, this.label1.Location.Y);
if (LPos.Y < FHeight)
{
if (LPos.Y < -(loc_text / 2))
{
if (Bol)
{ if (Bo)
{
label2.Location = new Point(0, this.Height - 72);
panel1.Controls.Add(label2);
timer2.Enabled = true;
timer2.Interval = 300;
timer2.Start();
Bo = false;
Bol = false;
}
}
}
if (LPos.Y < -loc_text)
{
timer1.Stop();
}
this.label1.Location = new Point(LPos.X, LPos.Y - 10);
return;
}
else
{
this.label1.Location = new Point(0, 0);
}
} private void timer2_Tick(object sender, EventArgs e)
{
int FWidth = this.panel1.Width;
int FHeight = this.panel1.Height; Point LPos = new Point(this.label2.Location.X, this.label2.Location.Y);
if (LPos.Y < FHeight)
{
if (LPos.Y < -(loc_text / 2))
{
if (!Bo)
{
timer1.Start();
this.label1.Location = new Point(0, this.Height - 72);
Bo = true;
} }
if (LPos.Y < -loc_text)
{
timer2.Stop(); Bol = true;
} this.label2.Location = new Point(LPos.X, LPos.Y - 10);
return;
}
else
{
this.label2.Location = new Point(0, 0);
}
} private void JCZ_SendNews_Load(object sender, EventArgs e)
{
this.label1.Location = new Point(0, this.Height - 72);
label1.Text = " 紧急通知\n由于近期物价高涨,燃油价格也高涨,反正就是什么都贵了。为了体现中国加入WTO与国际接轨的精神,本店铺也将提价10%,表示对国家的物质文明建设的贡献!"; int sumChar = label1.Text.Length;
int rowCount = (sumChar / 10) + 1;
label1.Height = rowCount * 100;
loc_text = rowCount * 100;
label1.Size = new Size(1024, label1.Height);
label1.Font = new Font("黑体", 72);
label1.ForeColor = Color.Red; label2.Text = label1.Text;
sumChar = label2.Text.Length;
rowCount = (sumChar / 10) + 1;
label2.Height = rowCount * 100;
label2.Size = new Size(1024, label2.Height);
label2.Font = new Font("黑体", 72);
label2.ForeColor = Color.Red; this.BackColor = Color.Black; this.timer1.Enabled = true;
this.timer1.Interval = 300;
this.timer1.Start(); }解决了……。办法是通过,两个label,的涵接来实现……。散分,结贴!