windows 已经定义了一个名为 'InitializeComponent' 的成员,具有相同的参数类型
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6717757/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Already defines a member called 'InitializeComponent' with the same parameter types
提问by Jay
I am trying to call the InitializeComponent method, although I get the following error:
我正在尝试调用 InitializeComponent 方法,但出现以下错误:
Type 'WindowsFormsApplication1.Form1' already defines a member called 'InitializeComponent' with the same parameter types
Code as follows:
代码如下:
public Form1()
{
InitializeComponent();
}
............
………………
private void InitializeComponent()
{
this.Browser = new WebBrowser();
this.panel1 = new Panel();
this.txtNavigate = new TextBox();
this.cmdGo = new Button();
}
}
回答by BennyM
There's already a method called InitializeComponent defined, check the designer generated code.
已经定义了一个名为 InitializeComponent 的方法,检查设计器生成的代码。
回答by lapadets
Change the privatekey word with partial:
使用partial更改私钥:
partial void InitializeComponent()
This way you can have as many members with the same name as you want.
通过这种方式,您可以拥有任意数量的同名成员。