0

私はc#を初めて使用し、タイトルで説明した方法に問題があります。コードが少し長いので、pastebinに投稿しました。32feet.net APIを使用して、Bluetoothデバイスをリストにリストしています。

問題は43行目と50行目にあり、次のステートメントがあります。

エラー1タイプ「WindowsFormsApplication1.Form1」は、同じパラメータータイプC:\ Users \ andre \ document \ visual studio 2010 \ Projects \ blueetoth \ blueetoth \ Form1.cs 4333blueetothで「Dispose」というメンバーを既に定義しています。

*エラー2タイプ「WindowsFormsApplication1.Form1」は、同じパラメータータイプC:\ Users \ andre \ document \ visual studio 2010 \ Projects \ blueetoth \ blueetoth \ Form1.cs 50 22blueetoth*で「InitializeComponent」というメンバーを既に定義しています。

Pastebin: http: //pastebin.com/LFEvaz2X

短いバージョン:dispose()

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

短いバージョン: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);

    }
4

1 に答える 1

1

フォームデザイナは部分クラスを採用しています-InitializeComponentメソッドはそこで定義されています。コードでフォームを自分で作成する場合は、デザイナーを使用せずに、通常のクラスを作成してForm自分から派生させます。

Dispose同様に定義されているようで、オーバーライドできないため、とにかくメソッドは必要ありません。

于 2010-11-20T13:54:50.150 に答える