メイン フォーム (Form1) への参照を渡す必要があるユーザー コントロール (section1) があります。問題は、フォームを section1 のコンストラクターに引数として渡すたびに、デザイナーが壊れてエラーが発生することです。
Type 'M.section1' does not have a constructor with parameters of types Form.
The variable 's1' is either undeclared or was never assigned.
Form1.Designer.cs
this.s1 = new M.section1(this); // this is the line that causes the problem
section1.csユーザー コントロール
public partial class section1 : UserControl
{
private Form1 f { get; set; }
public section1(Form1 frm) // constructor
{
f = frm;
}
}
デザイナーで Form1 を開くとエラーが表示されますが、正常にコンパイルされ、参照が実際に機能し、ユーザー コントロールから Form1 にアクセスできるのは奇妙です。助言がありますか?ありがとう!