using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;namespace Applications { public partial class Form1 : Form { Control.ControlCollection ctrls; public Form1() { InitializeComponent(); ctrls = this.Controls; } int count = 0; private void timer1_Tick(object sender, EventArgs e) { for (int i = 0; i < ctrls.Count; i++) { ctrls[i].BackColor = Color.White; }
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;namespace Applications
{
public partial class Form1 : Form
{
Control.ControlCollection ctrls;
public Form1()
{
InitializeComponent();
ctrls = this.Controls;
} int count = 0;
private void timer1_Tick(object sender, EventArgs e)
{
for (int i = 0; i < ctrls.Count; i++)
{
ctrls[i].BackColor = Color.White;
}
ctrls[count].BackColor = Color.Red;
count++;
if (count >= ctrls.Count)
{
count = 0;
}
} private void Form1_Load(object sender, EventArgs e)
{ }
}
}
// LabelList为100个label形成的list
LabelList[i].BackColor = Color.White;
i = (i+1)%100;
LabelList[i].BackColor = Color.Red;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;namespace 跑马灯2
{
public partial class Form1 : Form
{
// Control.ControlCollection ctrls;
public Form1()
{
InitializeComponent();
// ctrls = gB.Controls;
} int i = 1;
private void btnStart_Click(object sender, EventArgs e)
{
timer1.Interval = 100;
timer1.Enabled = true;
} private void timer1_Tick_1(object sender, EventArgs e)
{
// i++;
if (i > 100)
{
i = 1;
}
Label lb = (Label)gB.Controls.Find("label" + i, true)[0];
lb.BackColor = Color.Red;
if (i == 1)
{
label100.BackColor = System.Drawing.SystemColors.Control;
}
else
{
Label bb = (Label)gB.Controls.Find("label" + (i - 1), true)[0];
bb.BackColor = System.Drawing.SystemColors.Control;
}
i++;
}
}
}