【发布时间】:2015-10-11 08:10:33
【问题描述】:
我目前正在编写一个需要商店的游戏。我计划制作 1 个按钮打开商店/显示您可以购买的所有东西的按钮。我目前很难将按钮添加到实际窗口。 “contorls”功能未作为选项显示。
for (int i = 0; i < weaponsList.Count; i++)
{
Button newButton = new Button();
newButton.Name = Convert.ToString(i);
newButton.Content = weaponsList[i].WeaponName += weaponsList[i].MinDamage += weaponsList[i].MaxDamage += weaponsList[i].Cost;
newButton.Visibility = Visibility.Visible;
newButton.Width = 502;
newButton.Height = 78;
}
for 循环是为了不断添加武器数量的按钮。我试过做控制的事情,但没有奏效。
【问题讨论】:
-
你把所有的按钮都放在同一个位置。你遮住了下面的按钮?
-
使用:this.Controls.Add(newButton);不要忘记使用 tablelayoutpanel :-)