我必须在 .NET windows 应用程序中创建一个选取框。用 C# 最好的方法是什么?
问问题
13470 次
3 回答
4
只需放置一个ProgressBar
控件并将其更改Style
为Marquee
来自设计器。您将立即看到动画。
如果您指的是文本选取框,只需放置一个Label
控件并使用Timer 类来增加Location.X
标签的属性。当 X 坐标等于控件的大小时,只需将其重置并重新开始。
于 2011-06-03T06:07:50.573 回答
4
这是有关如何在 C# 中进行选取框的简单代码
private int xPos=0;
public Form1()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
if (this.Width == xPos)
{
//repeat marquee
this.lblMarquee.Location = new System.Drawing.Point(0, 40);
xPos = 0;
}
else
{
this.lblMarquee.Location = new System.Drawing.Point(xPos, 40);
xPos++;
}
}
private void Form1_Load(object sender, EventArgs e)
{
timer1.Start();
}
于 2011-06-03T06:21:26.800 回答
0
private void button_Click(object sender, EventArgs e)
{
int j = 100;
for (int i = 0; i < j; i++)
{
Thread.Sleep(5);
label3.Location = new System.Drawing.Point(0 + i, 111);
label3.Visible = true;
}
for (int i = j; i-- > 0; )
{
Thread.Sleep(15);
label3.Location = new System.Drawing.Point(0 + i, 111);
label3.Visible = true;
if (i < 1)
button_Click(sender, e);
}
}
于 2013-06-08T12:01:39.943 回答