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