2012-07-02 39 views
0

我正在嘗試添加一個簡單的工具條,但是我無法將它顯示在屏幕上 這裏是所有與之相關的代碼。我有沒有留下什麼?未能顯示工具條

場:

protected ToolStrip _commandToolStrip = new ToolStrip(); 

在構造

 FillToolBar(); 
    _commandToolStrip.Visible = true; 
    _commandToolStrip.BringToFront(); 

方法:

private void FillToolBar() 
    { 

    _commandToolStrip.Dock = DockStyle.Right; 
    _commandToolStrip.Visible = true; 
    ToolStripButton commandButton = new ToolStripButton("test", convertIconToImage((System.Drawing.Icon)(resources.GetObject("$this.Icon"))), Command_NextWebPattern_Execute); 
    _commandToolStrip.Items.Add(commandButton); 
    } 

    private Image convertIconToImage(Icon icon) 
    { 
     Bitmap bm = icon.ToBitmap(); 
     Image convertedImage = bm; 
     return convertedImage; 
    } 

我似乎無法找到任何理由爲什麼它不顯示。

+1

你在哪裏添加它到你的表單?即'this.Controls.add(_commandToolStrip)' – Adam

回答

1

幾乎就在我張貼的問題,發現問題..洛爾

我需要肯定的是,家長設置爲我的形式

ToolStrip的父母從未設定。我會把問題留給任何犯同樣的愚蠢錯誤的人:P