【发布时间】:2014-02-09 13:10:08
【问题描述】:
我无法按我的意愿显示控件。我是一名初学者程序员,在表单方面非常如此,因此非常感谢任何帮助。
public void CreateCard(Card card)
{
CardGUI topCard = new CardGUI(card);
topCard.Location = new Point(50, 50);
aPanel.Controls.Add(topCard);
DrawPlacement(topCard);
}
public void DrawPlacement(CardGUI cardGui)
{
cardGui.Location = new Point(a, b);
a += 18; // Space the cards
// Put the cards on a new line after half have been laid out.
counter++;
if (counter == 26)
{
a = 140;
b = 130;
}
this.Update();
aPanel.Controls.Add(cardGui);
cardGui.BringToFront();
}
我的问题是我希望在CreateCard 中添加到面板的控件以及在DrawPlacement 中添加的控件都显示出来。但是CreateCard 中的控件没有按预期显示。如果我评论了对DrawPlacement 的调用,我确实会出现,所以我认为这与Location 属性有关?
我已经尝试了各种各样的东西,但到目前为止没有任何效果。
【问题讨论】:
-
你在哪里定义a和b?
-
它们是全局定义的。让我在开始新牌组时更容易重置它们(我想)。