0
我做了一個浮動按鈕。我希望它佔據它所包含的整個表單,但下面的代碼在按鈕的右邊和表單的右邊之間有一個邊距。如何讓一個按鈕佔據整個包含的表單?
public FloatButton()
{
InitializeComponents();
int width = (int)((double)Screen.PrimaryScreen.Bounds.Width/20);
int height = (int)((double)Screen.PrimaryScreen.Bounds.Height/20);
this.WindowState = FormWindowState.Normal;
FormBorderStyle = FormBorderStyle.None;
int x_pos = Screen.PrimaryScreen.Bounds.Width - width;
int y_pos = Screen.PrimaryScreen.Bounds.Height/2 - height/2;
this.Location = new Point(x_pos,y_pos);
this.Height = height;
this.Width = width;
this.button.Width = width;
this.button.Height = height;
}
編輯:這是關於40個像素,如果我做的按鈕文本較長(文字環繞)
差距有多大?間隙的大小是否隨着按鈕的內容而變化? – ChrisF
嘗試將其放置在面板中並停靠。 – Luftwaffe