現在、C#Windowsフォームプロジェクトを作成中です。外部関数からフォームのプロパティを変更するC#
私は3つのWindowsフォーム - FormA、FormB、FormC、およびツールと呼ばれる外部クラスファイルを持っています。
私が望むのは、呼び出されたときに各フォームのプロパティを変更できる関数を作成することです。私は、これが私の機能の議論として渡され、使われるべきだと感じています。
これはTools.csコード:
public class Tools
{
public static void FullScreenMode(/*Should Pass a form's instance?*/)
{
FormBorderStyle = FormBorderStyle.None;
WindowState = FormWindowState.Maximized;
Screen screen = Screen.FromPoint(Cursor.Position);
this.Location = screen.Bounds.Location;
}
}
私はプロジェクトをビルドするとき、今、私は次のエラー
Error 5 'System.Windows.Forms.FormBorderStyle' is a 'type' but is used like a 'variable' C:\Users\AGDS\Dropbox\UniPi\5th\User Experience\Smart City\SmartCity\SmartCity\Tools.cs 72 13 SmartCity
Error 6 The name 'WindowState' does not exist in the current context C:\Users\AGDS\Dropbox\UniPi\5th\User Experience\Smart City\SmartCity\SmartCity\Tools.cs 73 13 SmartCity
Error 7 Keyword 'this' is not valid in a static property, static method, or static field initializer C:\Users\AGDS\Dropbox\UniPi\5th\User Experience\Smart City\SmartCity\SmartCity\Tools.cs 75 13 SmartCity
あなたが見つけたエラーが登場:this.FormBorderStyle –