感谢社区的帮助,我已经能够在选项卡控件中放入一个动态标签,将值保存到一个列表中,然后随意调用它。现在继续下一个问题,如果我想为每个动态标签输出每一行,我会怎么做?下面是我的代码:
private void frmYourCart_Load(object sender, EventArgs e)
{
if (InvoiceRental.GetTitle().Count > 0)
{
//page 215
for (int i = 0; i < InvoiceRental.GetTitle().Count; i++)
{
lblConsole.Visible = true;
lblTitle.Visible = true;
lblPrice.Visible = true;
Label resultLabel = new Label();
resultLabel.AutoSize = true;
resultLabel.Location = new Point(160, 200);
resultLabel.Anchor = (AnchorStyles.Top | AnchorStyles.Left);
resultLabel.Text += String.Format("{0, 50} {1, 50}\n", InvoiceRental.GetTitle()[i], InvoiceRental.GetPrice()[i]);
this.Controls.Add(resultLabel);
}
}