![](/img/trans.png)
[英]Why doesn't the Controls collection provide all of the IEnumerable methods?
[英]Why doesn't all my controls show?
我在按要求顯示控件時遇到問題。 我是一個初學者,在表單方面非常重要,因此對您的幫助非常感謝。
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
的調用,我會DrawPlacement
,所以我認為它與Location
屬性有關嗎?
我嘗試過各種方法,但到目前為止沒有任何效果。
類型的對象CardGUI
您在添加DrawPlacement
是一樣的一個中添加CreateCard
因此增加它什么都不做。
如果你想,你應該創建另一個相同位置相同的對象2倍CardGUI
看起來酷似一個冷杉在DrawPlacement
,而不是操縱原始對象。
public void CreateCard(Card card)
{
CardGUI topCard = new CardGUI(card);
topCard.Location = new Point(50, 50);
aPanel.Controls.Add(topCard);
DrawPlacement(card);
}
public void DrawPlacement(Card card)
{
CardGUI cardGui = new CardGUI(card);
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();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.