我正在设计一个简单的扩展器控件.
我派生自UserControl,绘制内部控件,构建,运行; 一切都好.
由于内部控件是Panel,我想在设计时将其用作容器.的确,我使用了以下属性:
[Designer(typeof(ExpanderControlDesigner))]
[Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", typeof(IDesigner))]
Run Code Online (Sandbox Code Playgroud)
太棒了,我说.但它不是......
结果是我可以在设计时将它用作容器,但是:
我错过了什么?这是完整性的代码...为什么这段代码不起作用?
[Designer(typeof(ExpanderControlDesigner))]
[Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", typeof(IDesigner))]
public partial class ExpanderControl : UserControl
{
public ExpanderControl()
{
InitializeComponent();
....
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")]
internal class ExpanderControlDesigner : ControlDesigner
{
private ExpanderControl MyControl;
public override void Initialize(IComponent component)
{
base.Initialize(component);
MyControl = (ExpanderControl)component;
// Hook up events
ISelectionService s = (ISelectionService)GetService(typeof(ISelectionService));
IComponentChangeService c = (IComponentChangeService)GetService(typeof(IComponentChangeService));
s.SelectionChanged += new EventHandler(OnSelectionChanged);
c.ComponentRemoving += new ComponentEventHandler(OnComponentRemoving);
}
private void OnSelectionChanged(object sender, System.EventArgs e) …Run Code Online (Sandbox Code Playgroud) 我在WinForms桌面应用程序中使用Microsoft splitcontainer控件(.net 4/c#/ vs 2010).
我想在spliiter控件的面板之间放一个小按钮(或任何漂亮的UI元素)来折叠其中一个面板.例如,一个"按钮"有两个部分,如果我点击一个部分,右侧面板会折叠,如果我点击另一个部分,左侧面板会折叠.
我怎么能解决这个问题呢?
Thx提前!