我正在尝试根据需要在面板中执行一些操作,并将现有添加的按钮的位置更改为新位置。
public class MyPanel : Panel
{
protected override OnPaint()
{
// Added the controls.
// Done some operations which needs the location change.
// Changed the location of the buttons.
}
}
但是控件在面板中不可见。
只有在不更改位置的情况下,面板上才能正确显示控制。
请问任何人,为什么动态更改位置时面板上未显示控件?
答案 0 :(得分:0)
将此添加到您的项目
Control board = panel1;
Button But = new Button()
{
Size = new Size(size, size),
Location = new Point(x, y),
....
};
board.Controls.Add(But);