2010-11-20 8 views
0

私はC#の新機能であり、タイトルで教えた方法に問題があります。コードは少し長いので、pastebinに投稿しました。私は32feet.net APIを使用してリスト内のBluetoothデバイスをリストアップしています。C#で問題を起こすdispose()とinitializeComponent()メソッド

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

エラー1型「WindowsFormsApplication1.Form1」は既に同じパラメータタイプCで「廃棄」と呼ばれるメンバーを定義しています:\ユーザー\アンドレ\プロジェクト\ Visual Studioの2010 \ドキュメント\ blueetoth \ blueetoth \ Form1.csの43 33 blueetoth

* エラー2種類 'WindowsFormsApplication1.Form1' は既にと呼ばれるメンバーを定義する 'のInitializeComponent' は同じパラメータでC:\ Userの種類http://pastebin.com/LFEvaz2X

ショートバージョン::処分()

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

短いS \アンドレ\プロジェクト\ Visual Studioの2010 \ドキュメント\ blueetoth \ blueetoth \ 50 22 blueetoth *

ペーストビンのForm1.csバージョン: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); 

    } 

答えて

1

フォームデザイナーは、部分クラス - InitializeComponentメソッドが定義されています。あなた自身のコードでフォームを作成したい場合は、デザイナーを使わずに通常のクラスを作成してFormから派生させてください。

Disposeも同様に定義されているようで、オーバーライドできないので、あなたの方法は必要ありません。

+0

okちょっとわかりました。C#:-) – Andre

関連する問題