我做了一个浮动按钮。我希望它占据它包含的整个表单,但下面的代码在按钮右侧和表单右侧之间有一个边距。
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 像素,如果我让按钮文本更长(文本换行),它不会改变