我想在Winform中做一个跑马灯,也就是让一行字在上面滚动,上次在这里发帖了,但是效果不怎么好,我现在不想用timer控件+label来实现,因为这样的效果是跳动的,如果在屏幕上显示效果不好。我想用pictures重绘,因为我最终是在显示在Led显示屏上面,具体要求就是滚动的范围可以自己设置,效果是平滑滚到,不是跳动的。希望大家帮我想想,如果问题解决了,我还会加分的。
解决方案 »
- winform中如何根据变量设置DataGridView中控件的值。
- 求一段ASP.NET(C#)将excel中数据导入到sql2000数据表中代码。
- radiobutton的问题
- JavaScript中出现的错误怎样跟踪?怎样定位?
- 问一个有关split的问题,忘大家帮忙
- 为什么我在右框架放入一个表格width设置为100%,但是表格总是不能补满右边界呢?有高手了解这个问题吗?
- Cookie通用的问题
- 有三个网页制作的基础问题向大家请教:(在线,解决马上结贴)
- 关于ASP.NET的两个亟待弄清的问题!
- 谷歌下,js获取<input type="file" ... />绝对路径失败,被修改成C:\fakepath\...形式
- 微软有没有可能在不久的将来发布一个替代IIS的web server软件
- ValidateRequest="false" 为什么会截掉部分文本?
{
if (labMsg.Location.X < 0 && Math.Abs(labMsg.Location.X) - labMsg.Width >= 0)
{
labMsg.Location = new Point(panel1.Width, labMsg.Location.Y);
return;
}
labMsg.Location = new Point(labMsg.Location.X - 5, labMsg.Location.Y);
}
[Category("Appearance"),
Description("Label前景色")]
public System.Drawing.Color LabelForeColor
{
get { return labMsg.ForeColor; }
set { labMsg.ForeColor = value; }
} [Category("Appearance"),
Description("LabelText")]
public string LabelText
{
get { return labMsg.Text; }
set
{ labMsg.Text = value;
if (value == "")
timer1.Enabled = false;
else timer1.Enabled = true;
}
}
还有一个方法就是用API来做,以前看过一个VB6的例子,那个效果比较好,平滑。
还是帮你顶哈
public static int x = 0;
public static float w = 0;//滚到的长度
public static float step = 0; //每次滚动的像素
public static string data = "";//滚到的内容
public static Font myfont = new Font("宋体",12);
public static Color picScollColor = Color.Green;
//滚动条滚动
private void timer2_Tick(object sender, EventArgs e)
{
if (step > w)
{
x = picScoll.Width;
step = 0;
}
Bitmap myPic = new Bitmap(picScoll.Width, myfont.Height);
Graphics g = Graphics.FromImage(myPic);
SizeF f = g.MeasureString(data,myfont);
w = f.Width + picScoll.Width;
Brush brush = new SolidBrush(picScollColor);
g.DrawString(data,myfont ,brush ,new Point (x,0));
picScoll.Image = myPic;
step++;
x--;
}