舒尔特表(问题出在哪里?)
protected void Button1_Click(object sender, EventArgs e)
{
int a = int.Parse(DropDownList1.SelectedItem.Value);
int[] b;
int[] d;
int c = a * a;
b=new int[c];
d=new int[c];
for (int k = 0; k <c; k++)
{
b[k] = k + 1;
}
/*本打算自己把这个小程序完成的,干了一整天,发现确实力有不逮,请高手帮忙(老了想学都难咯)
这是一个舒尔特表,已经基本成型,但是不知道什么原因,最后一格要么是1,要么是25,不是随机的,请问各位,问题出在哪里
现在还不能点击变色,不能计时,只好等明天了。
.net2.0
*/
for (int i = 0; i < a; i++)
{
Literal hang = new Literal();
hang.Text = " <br> ";
Panel1.Controls.Add(hang);
for (int j = 0; j < a; j++)
{
Button hj = new Button();
hj.ID = "hj " + i;
Random ran = new Random(DateTime.Now.Millisecond);
int suijishu = ran.Next(1, c + 1);
hj.Text = b[suijishu-1].ToString();
d = new int[c-1];
for (int l = 0; l < suijishu-1; l++)
{
d[l] = b[l];
}
for (int m = suijishu; m <c ; m++)
{
d[m-1] = b[m];
}
b = d;
c--;
hj.Width = 30;
hj.Height = 30;
//hj.CommandName = "gaise ";
//hj.BackColor = System.Drawing.Color.LightSkyBlue;
Panel1.Controls.Add(hj);
Label1.Text = DateTime.Now.ToString();
}
}
}
[解决办法]
protected void Page_Load(object sender, EventArgs e)
{
Button1.Click += new EventHandler(bt);
}
protected void bt(object sender,EventArgs e)
{
Response.Write( "aabb ");
}
楼主复习一下委托,呵呵。