0

这适用于 windows 桌面,而不是 asp.net。我有一个面板,我正在向其中添加项目。现在这些项目正在显示,但在彼此之上。我希望它们之间用空行隔开。我究竟做错了什么?

string[] stng = { "1", "2" };
foreach (string stng123 in stng)
{
    Panel entryPanel = new Panel();
    Label lbInfo = new Label();
    lbInfo.AutoSize = true;
    lbInfo.Text = "stng123 + Environment.NewLine + "testing";

    Button delButton = new Button();
    delButton.Text = "Delete";
    delButton.Location = new Point(120, 0);
    delButton.Click += (s, e) => { panel1.Controls.Remove(entryPanel); };

    panel1.Controls.Add(entryPanel);
    entryPanel.Controls.Add(lbInfo);
    entryPanel.Controls.Add(delButton);
    entryPanel.BackColor = System.Drawing.Color.FromArgb(100, 255, 240, 0);
}
panel1.Height = (panel1.Controls.Count) + 88;
4

0 回答 0