读书人

选号系统 数字上下滚动有关问题

发布时间: 2013-10-23 11:39:13 作者: rapoo

选号系统 数字上下滚动问题
好:
近期想做一个随机选号系统,已经实现数字随机变换选号效果;现打算将数字变换修改为上下随机滚动效果,现在遇到如下问题:
1、随机变换,我使用的修改label.text属性实现,但是上下滚动不可能
请问各位有什么好的建议

代码如下,利用的是Panel的固定大小,挡住Label的其他部分,让Label上下移动,只显示一个数字(这里就要主要的是Label在Panel上面,而不是直接在Form上面,才能达到滚动的效果)

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Threading;

namespace TestWinForm
{
public partial class FormTest : Form
{
public FormTest()
{
InitializeComponent();
}

private bool isStart = true;

private void Test()
{
Point current = lblNumberArr.Location;
int y = 0;
bool up = true;
while (isStart)
{
if (y == -lblNumberArr.Size.Height)
{
up = false;
}
else if (y == 0)
{
up = true;
}

if (up)
{
y = current.Y - 1;
}
else
{
y = current.Y + 1;
}

lblNumberArr.Invoke(new Action(delegate()
{

lblNumberArr.Location = new Point(current.X, y);
lblNumberArr.Refresh();
}));

Thread.Sleep(10);
current = lblNumberArr.Location;
}
}

private Thread thread = null;

private void btnStart_Click(object sender, EventArgs e)
{
if (thread == null
[解决办法]
!thread.IsAlive)


{
thread = new Thread(new ThreadStart(Test));
thread.Start();
}
}

private void btnStop_Click(object sender, EventArgs e)
{
if (thread.IsAlive)
{
thread.Abort();
}
}
}
}


[解决办法]

选号暂停了要显示完整一个数字啊~选号系统 数字上下滚动有关问题
要计算好控件的大小,滑动的时候整个控件滑动就可以显示整个数字了


我也小试一下,不过楼主好像不是要winform的选号系统 数字上下滚动有关问题

选号系统 数字上下滚动有关问题

读书人网 >C#

热点推荐