简体   繁体   中英

dispose() and initializeComponent() method in C# make problems

I'm new to c# and have a problem with the methods i've told you in the title. the code is a little bit long so i posted it to pastebin. i'm using the 32feet.net api to list up bluetooth devices in a list.

the problems are in line 43 and 50 with the following statement:

Error 1 Type 'WindowsFormsApplication1.Form1' already defines a member called 'Dispose' with the same parameter types C:\\Users\\andre\\documents\\visual studio 2010\\Projects\\blueetoth\\blueetoth\\Form1.cs 43 33 blueetoth

and

* Error 2 Type 'WindowsFormsApplication1.Form1' already defines a member called 'InitializeComponent' with the same parameter types C:\\Users\\andre\\documents\\visual studio 2010\\Projects\\blueetoth\\blueetoth\\Form1.cs 50 22 blueetoth *

Pastebin: http://pastebin.com/LFEvaz2X

short version: dispose()

protected override void Dispose(bool disposing)
{
     base.Dispose(disposing);
}

short version: initializeComponent

private void InitializeComponent()
    {
        this.mainMenu1 = new System.Windows.Forms.MainMenu();
        this.listBox1 = new System.Windows.Forms.ListBox();
        // 
        // listBox1
        // 
        this.listBox1.Location = new System.Drawing.Point(14, 14);
        this.listBox1.Size = new System.Drawing.Size(212, 212);
        // 
        // Form1
        // 
        this.ClientSize = new System.Drawing.Size(240, 268);
        this.Controls.Add(this.listBox1);
        this.Menu = this.mainMenu1;
        this.MinimizeBox = false;
        this.Text = "Form1";
        this.Load += new System.EventHandler(this.Form1_Load);

    }

The forms designer employs partial classes - the InitializeComponent method is defined there. If you want to create your form in code yourself, don't use the designer but create a normal class and derive from Form yourself.

Dispose seems to be defined as well and isn't overrideable, so you don't need your method anyway.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM