gpt4 book ai didi

c# - 为什么我的面板不显示我的 C# 应用程序中的所有按钮?

转载 作者:太空宇宙 更新时间:2023-11-03 19:34:11 24 4
gpt4 key购买 nike

我的 Windows 窗体应用程序中的面板不包含我要求的所有按钮。它只显示 1 个按钮,这是代码

 private void AddAlphaButtons()
{
char alphaStart = Char.Parse("A");
char alphaEnd = Char.Parse("Z");

for (char i = alphaStart; i <= alphaEnd; i++)
{
string anchorLetter = i.ToString();
Button Buttonx = new Button();
Buttonx.Name = "button " + anchorLetter;
Buttonx.Text = anchorLetter;
Buttonx.BackColor = Color.DarkSlateBlue;
Buttonx.ForeColor = Color.GreenYellow;
Buttonx.Width = 30;
Buttonx.Height = 30;

this.panelButtons.Controls.Add(Buttonx);

//Buttonx.Click += new System.EventHandler(this.MyButton_Click);
}
}

最佳答案

他们不都在同一个位置上吗?

尝试设置 Buttonx.Location = new Point(100, 200);

(但不同的按钮有不同的点)

关于c# - 为什么我的面板不显示我的 C# 应用程序中的所有按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2976614/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com