111,130
社区成员
发帖
与我相关
我的任务
分享
<asp:TextBox ID="TextBox1" runat="server" BackColor="White"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" BackColor="White"></asp:TextBox>
<asp:TextBox ID="TextBox3" runat="server" BackColor="White"></asp:TextBox>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
<asp:Label ID="Label1" runat="server" Text="0" Visible="false"></asp:Label>
TextBox[] tx = new TextBox[3];
tx[0] = TextBox1;
tx[1] = TextBox2;
tx[2] = TextBox3;
int i = int.Parse(Label1.Text);
for (int j = 0; j < tx.Length; j++)
{
if (j == i)
{
tx[j].BackColor = Color.Red;
}
else
{
tx[j].BackColor = Color.White;
}
}
i++;
if (i == tx.Length)
{
i = 0;
}
Label1.Text = i.ToString();
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1: Form
{
public Form1()
{
InitializeComponent();
InitializeUserCom();
}
/// <summary>
/// describe:tbs
/// </summary>
public TextBox[] Ptbs
{
get;
set;
}
private void InitializeUserCom()
{
this.Ptbs = new TextBox[] {
this.textBox1,
this.textBox2,
this.textBox3,
this.textBox4,
this.textBox5,
this.textBox6,
this.textBox7,
this.textBox8,
};
this.Pindex = 0;
}
/// <summary>
/// index:index
/// </summary>
public int Pindex
{
get;
set;
}
private void button1_Click(object sender, EventArgs e)
{
if (this.Pindex<9)
{
this.Pindex++;
}
else
{
this.Pindex = 0;
}
this.SetTb(this.Pindex);
}
private void SetTb(int p)
{
for (int i = 0; i < this.Ptbs.Length; i++)
{
if (p==i)
{
this.Ptbs[i].BackColor = Color.White;
}
else
{
this.Ptbs[i].BackColor = Color.Gray;
}
}
} }
}