2013-01-06 42 views
0

我有一些用戶控件的程序,但是當我構建解決方案時,用戶控件不會出現在工具箱上,因爲測試我做了另一個用戶控件,並且在重新構建後出現工具箱 !這是我的用戶控件中的一個:我的用戶控件不會出現在工具箱中

using System.Drawing; 
using System.Windows.Forms; 

namespace AMIgo 
{ 
    /// <summary>A UserControl used to display and interact with the active calls.</summary> 
    /// <remarks>This display reflect the content of the <see cref="AMI_Client.AstCallsList"/> which contains the current active calls. 
    /// The ListViewCalls display allows to show the items in differents layouts, in a similar way than the windows file explorer. 
    /// <para>A menu allows to select to display Inbound(show in Red (default), Outbound (shown in blue) and internal (shown in gray) calls.</para> 
    /// <para>Properties allows to set the font and colors of the ListView and ListItems</para> 
    /// <para>Drag/Drop: You can drag an active call and drop it onto an extension in the <see cref="ListViewLines"/> display to Transfer a 
    /// caller to an extension. You can drag and drop an active call to the display toolbar drop target to Transfer the active channel to the 
    /// selected destination, to park the call or to hang it up. You can also drag an active channel to the <see cref="AMIgoDropTarget"/> form to Transfer a call to the selected destination. 
    /// (Extension, queue, conference, etc)</para> 
    /// <para> Context Menu: Right click on an item to open a Context menu.</para> 
    /// <seealso cref="AstCall"/><seealso cref="AMI_Client.NewCallEvent"/></remarks> 
    [ToolboxBitmap(typeof(AMIgo.ListViewCalls), "Resources.Control_ListView.bmp")] 
    public partial class ListViewCalls : AMIgoControl 
    { 
    /// <summary>Gets or sets a value indicating whether the intermediary agents channels are displayed.</summary> 
    /// <value><c>true</c> to show Agents channels otherwise, <c>false</c>.</value> 
    public bool ShowAgentsChannels { get; set; } 
    private bool _show_outbound_calls; 
    /// <summary>Gets or sets a value indicating whether the outbound calls are displayed.</summary> 
    /// <value><c>true</c> to show outbound calls, otherwise, <c>false</c>.</value> 
    public bool ShowOutboundCalls 
    { 
     get { return (_show_outbound_calls); } 
     set 
     { 
     _show_outbound_calls = value; 
     outboundToolStripMenuItem.Checked = _show_outbound_calls; 
     } 
    } 
    private bool _show_internal_calls; 
. 
. 
. 
. 
. 

,這是AMIgoControl文件...

using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Windows.Forms; 

namespace AMIgo 
{ 
    /// <summary> 
    /// This is the base control from which inherit most of the AMIgo controls 
    /// </summary> 
    [DesignTimeVisible(false)] 
    [System.ComponentModel.ToolboxItem(false)] 
    public class AMIgoControl : UserControl 
    { 
    /// <summary>true after this control has been initialized. </summary> 
    public bool _InitDone; 
    /// <summary>Gets or sets the AMI_Client instance. The AMI_Client component will set this on startup if left blank.</summary> 
    public virtual AMIgo.AMI_Client AMI_ClientInstance { get; set; } 
    /// <summary>Initializes a new instance of the <see cref="AMIgoControl"/> class.</summary> 
    public AMIgoControl() { } 
    /// <summary>Initializes a new instance of the <see cref="AMIgoControl"/> class. </summary> 
    /// <param name="AMI_ClientInstance">The AMI_Client instance.</param> 
    public AMIgoControl(AMIgo.AMI_Client AMI_ClientInstance) 
    { 
     this.AMI_ClientInstance = AMI_ClientInstance; 
    } 
    /// <summary>Finds a Control recursively. Note finds the first match and exits</summary> 
    /// <param name="Container">The container to search for the given control type. 
    /// Remember all controls (Panel, GroupBox, Form, etc are all containers for controls 
    /// </param> 
    /// <param name="TypeName">Name of the type of control to look for</param> 
    /// <returns>The control object if found or null</returns> 
    /// 
    public Control FindControlRecursive(Control Container, string TypeName) 
    { 
     if (Container.GetType().Name == TypeName) 
     return Container; 

     foreach (Control ctrl in Container.Controls) 
     { 
     Control foundCtrl = FindControlRecursive(ctrl, TypeName); 
     if (foundCtrl != null) 
      return foundCtrl; 
     } 
     return null; 
    } 

    } //UserControl 

回答

3

只爲首發:工具箱在VS應用上下文過濾器的話,你將不會看到用戶控制,除非你有一位設計師在文檔中打開並活躍。如果你已經嘗試了這個,但仍然沒有看到控件 - 你能發佈截圖以便更好地理解嗎?此外,請提及您使用的VS版本 - 我只是嘗試在VS12上創建一個樣本UC,並且它的工作方式與預期相同。也許,你可能也想做那個測試,並且發佈更新和結果。

更新:順便說一句,您可能想要刪除AMIgo類上的ToolboxItem(false)屬性。

+0

哦!順便說一下,您可能需要刪除AMIgo類上的「ToolboxItem(false)」屬性。 –

+0

我做了這樣的改變:// [DesignTimeVisible(false)] //[System.ComponentModel.ToolboxItem(false)]現在沒事了....非常感謝 – user1952408

+0

它工作嗎?如果您想要在工具箱中顯示ListViewCalls但隱藏基本控件AMIgoControl,請將兩個屬性應用於ListViewCalls並將它們設置爲true: [DesignTimeVisible(false)] [System.ComponentModel.ToolboxItem(false)] –

相關問題