1
C# 코드를 사용하여 패널 위쪽에 단추를 배치하는 방법은 무엇입니까?내 패널 위에 Button을 두는 방법은 무엇입니까?
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);
}
}
panel1
에button1
을 추가하거나 패널 위의 양식 것인가? 좀 더 자세하게 말해주세요. –@Charles : 예, 패널의 버튼을 원합니다. – HelpNeeder