私はC#でWebブラウザーを使用しているので、そのためのスプラッシュ画面を作成しました。ただし、起動時にスプラッシュ画面が画面の中央に配置されていません。では、フォームをスタートアップに集中させる方法はありますか?
作業コード:
public splash()
{
InitializeComponent();
StartPosition = FormStartPosition.CenterScreen;
}
StartPosition = FormStartPosition.CenterScreen;
form.StartPosition = FormStartPosition.CenterScreen;
MSDNを参照してください。
GUIから実行する場合で、Visual Studioを使用する場合は、次の手順を使用します
。1.フォームデザイナーでフォームを開きます
。2。フォームのプロパティに
移動します。3。[StartPosition]を[CenterScreen]に変更します。
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
//Method 1. center at initilization
this.StartPosition = FormStartPosition.CenterScreen;
//Method 2. The manual way
this.StartPosition = FormStartPosition.Manual;
this.Top = (Screen.PrimaryScreen.Bounds.Height - this.Height)/2;
this.Left = (Screen.PrimaryScreen.Bounds.Width - this.Width)/2;
}
}
}