我試圖用List
聲明Label
s。 我得到一個索引超出界限的錯誤。嘗試收集列表中的標籤時出現索引超出限制
下面是代碼:
using System.Windows.Forms;
using System.Collections.Generic;
namespace Player_editor
{
partial class Form3
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
labels[1] = new System.Windows.Forms.Label();
labels[2] = new System.Windows.Forms.Label();
labels[3] = new System.Windows.Forms.Label();
labels[4] = new System.Windows.Forms.Label();
labels[5] = new System.Windows.Forms.Label();
labels[6] = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
labels[1].AutoSize = true;
labels[1].Location = new System.Drawing.Point(12, 9);
labels[1].Name = "label1";
labels[1].Size = new System.Drawing.Size(35, 13);
labels[1].TabIndex = 0;
labels[1].Text = "label1";
//
// label2
//
labels[2].AutoSize = true;
labels[2].Location = new System.Drawing.Point(53, 9);
labels[2].Name = "label2";
labels[2].Size = new System.Drawing.Size(35, 13);
labels[2].TabIndex = 1;
labels[2].Text = "label2";
//
// label3
//
labels[3].AutoSize = true;
labels[3].Location = new System.Drawing.Point(12, 22);
labels[3].Name = "label3";
labels[3].Size = new System.Drawing.Size(35, 13);
labels[3].TabIndex = 2;
labels[3].Text = "label3";
//
// label4
//
labels[4].AutoSize = true;
labels[4].Location = new System.Drawing.Point(53, 22);
labels[4].Name = "label4";
labels[4].Size = new System.Drawing.Size(35, 13);
labels[4].TabIndex = 3;
labels[4].Text = "label4";
//
// label5
//
labels[5].AutoSize = true;
labels[5].Location = new System.Drawing.Point(12, 35);
labels[5].Name = "label5";
labels[5].Size = new System.Drawing.Size(35, 13);
labels[5].TabIndex = 4;
labels[5].Text = "label5";
//
// label6
//
labels[6].AutoSize = true;
labels[6].Location = new System.Drawing.Point(53, 35);
labels[6].Name = "label6";
labels[6].Size = new System.Drawing.Size(35, 13);
labels[6].TabIndex = 5;
labels[6].Text = "label6";
//
// Form3
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(239, 464);
this.Controls.Add(labels[6]);
this.Controls.Add(labels[5]);
this.Controls.Add(labels[4]);
this.Controls.Add(labels[3]);
this.Controls.Add(labels[2]);
this.Controls.Add(labels[1]);
this.Name = "Form3";
this.Text = "Groups";
this.Load += new System.EventHandler(this.Form3_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
List<System.Windows.Forms.Label> labels = new List<System.Windows.Forms.Label>();
}
}
您不應該在本節中添加您自己的代碼;它是由設計師自動生成的。 – BeemerGuy 2010-11-21 15:01:55