1
如何使用C#代碼在面板上放置按鈕?如何在我的面板上放一個按鈕?
public partial class SpaceExplorer : Form
{
Button btnPlayer = new Button();
Panel pGame = new Panel();
public SpaceExplorer()
{
InitializeComponent();
// panel: pGame
pGame.BackColor = System.Drawing.Color.Black;
pGame.Dock = System.Windows.Forms.DockStyle.Fill;
pGame.Location = new System.Drawing.Point(0, 24);
pGame.Name = "panelMain";
Controls.Add(pGame);
}
private void subMenuStart_Click(object sender, EventArgs e)
{
// button: btnPlayer
btnPlayer.Location = new System.Drawing.Point(0, 23);
btnPlayer.Name = "player";
btnPlayer.Size = new System.Drawing.Size(20, 20);
btnPlayer.BackColor = Color.White;
btnPlayer.Text = string.Empty;
btnPlayer.Enabled = false;
Controls.Add(btnPlayer);
}
}
添加
button1
你想要的按鈕實際上是面板或面板上方的形式?請多提供一些細節。 –@Charles:是的,我想要面板上的按鈕。 – HelpNeeder