2012-05-02 16 views
-3

IM喜試圖以編譯爲了解決這個問題,並不能找到一種方法通用參數錯誤

錯誤:

Pro\AGeeksToy\Controls\LadderHeader.cs(218,98): error CS0426: The type name 'menuData' does not exist in the type 'AGeeksToy.CoreDataTypes.AGeeksToyToolStripMenuItem>'

這是錯誤。

private void ChangeStakingType(AGeeksToyToolStripMenuItem<EnhancedType<StakingTypeEnum>>.menuData newType) 
    { 
     this.StakeBox.StakingType.Value = newType.Data.Value; 
    } 

AGeeksToyToolStripMenuItem類代碼:

namespace AGeeksToy.CoreDataTypes 
{ 
    using System; 
    using System.Windows.Forms; 

    public abstract class AGeeksToyToolStripMenuItem<T> : ToolStripMenuItem, AGeeksToyMenu 
    { 
     public MouseButtons LastMouseButton; 
     public MenuData<T> menuData; 
     public static readonly VoidEventWithParam<MenuData<T>> RightClicked; 

     static AGeeksToyToolStripMenuItem() 
     { 
      AGeeksToyToolStripMenuItem<T>.RightClicked = new VoidEventWithParam<MenuData<T>>(); 
     } 

     protected AGeeksToyToolStripMenuItem(T obj, string text) : this(obj, text, null) 
     { 
     } 

     protected AGeeksToyToolStripMenuItem(T obj, string text, Control ctrl) 
     { 
      base.DropDown.ImageList = IconManager.m_ImageList; 
      this.menuData = new MenuData<T>(obj, ctrl); 
      this.Text = text; 
     } 

     protected override void Dispose(bool disposing) 
     { 
      base.DropDown.ImageList = null; 
      base.Dispose(disposing); 
     } 

     protected override void OnClick(EventArgs e) 
     { 
      if (this.MenuControl != null) 
      { 
       this.MenuControl.Refresh(); 
      } 
      base.OnClick(e); 
      if (this.LastMouseButton == MouseButtons.Right) 
      { 
       AGeeksToyToolStripMenuItem<T>.RightClicked.TriggerEvent(this.menuData); 
      } 
     } 

     protected override void OnMouseDown(MouseEventArgs e) 
     { 
      this.LastMouseButton = e.Button; 
      base.OnMouseDown(e); 
     } 

     public virtual void SetMenu() 
     { 
      this.LastMouseButton = MouseButtons.Left; 
      if (this.MenuControl != null) 
      { 
       base.Visible = this.MenuControl.Visible; 
       this.Enabled = this.MenuControl.Enabled; 
      } 
      foreach (ToolStripItem item in base.DropDownItems) 
      { 
       if (item is AGeeksToyMenu) 
       { 
        (item as AGeeksToyMenu).SetMenu(); 
       } 
      } 
     } 

     public T Menu_Data 
     { 
      get 
      { 
       return this.MenuObject; 
      } 
     } 

     protected Control MenuControl 
     { 
      get 
      { 
       return this.menuData.Control; 
      } 
     } 

     protected T MenuObject 
     { 
      get 
      { 
       return this.menuData.Data; 
      } 
      set 
      { 
       this.menuData.Data = value; 
      } 
     } 


     public class MenuData<T> 
     { 
      public System.Windows.Forms.Control Control; 
      public T Data; 

      public MenuData(T obj, System.Windows.Forms.Control ctrl) 
      { 
       this.Data = obj; 
       this.Control = ctrl; 
      } 
     } 
    } 
} 

http://i.stack.imgur.com/XfUIA.png

編譯錯誤。

如果任何人都可以在這裏

Download Link Google Code

幹線也可用,但不能直接後鏈接來下載該項目或檢查源的產品尚未推出。

感謝您的任何幫助

+2

請做,你的調試,然後回來,所以... – Mahm00d

+0

這是在stackoverflow上最無用的問題之一。 – gdoron

回答

9

您在說您有一個名爲ChangeStakingType的私有無返回方法,它帶有一個參數。參數名稱爲「newType」,參數類型爲AGeeksToyToolStripMenuItem<EnhancedType<StakingTypeEnum>>.menuData。但在您的程序中沒有名爲menuData的類型。有一個名爲menuData的字段和一個名爲MenuData<T>的類型,但沒有稱爲menuData的類型。

0

C#區分大小寫。

您正試圖使用​​menuData類,當實際的類被稱爲MenuData。使M大寫