日期:2014-05-17 浏览次数:21013 次
string[] src = new string[dt.Rows.Count];
string src1;
for (int i = 0; i < dt.Rows.Count; i++)
{
Button btn = new Button();
src1 = dt.Rows[i].ItemArray[0].ToString();
src[i] = src1;
btn.BackColor = Color.Fuchsia;
btn.Font = new Font("黑体", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
btn.ForeColor = Color.White;
btn.Location = new Point(0, 42 * i);
btn.Name = src1;
btn.Size = new Size(773, 42);
//btn.TabIndex = 0;
btn.Text = src1;
btn.UseVisualStyleBackColor = false;
btn.Click += new EventHandler(btn_Click);
panel1.Controls.Add(btn);//这里报异常:NullReferenceException: 未将对象引用设置到对象的实例
}