我有一些用户控件的程序,但是当我构建解决方案时,用户控件没有出现在工具箱上,为了测试,我制作了另一个用户控件,重新构建后它出现在工具箱上!这是我的用户控件之一:
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