我创建了自己的 Tabcontrol 类,派生自 UserControl,因为我不喜欢现有 Tabcontrol 类的设计。它工作正常,但现在我想为控件添加设计时支持,我不知道如何开始。我已经阅读了一些教程,但没有一个解释如何创建 Tabcontrol。感谢帮助 ;)
编辑:
public class TabListDesigner : ParentControlDesigner
{
private DesignerVerb addVerb;
private DesignerVerb removeVerb;
private DesignerVerbCollection verbs;
protected TabList TabListControl { get { return this.Control as TabList; } }
public override DesignerVerbCollection Verbs
{
get
{
if (verbs == null)
{
verbs = new DesignerVerbCollection();
addVerb = new DesignerVerb("Add TabListPage", this.AddVerbHandler) { Description = "Add a new TabListPage to the parent control." };
removeVerb = new DesignerVerb("Remove TabListPage", this.RemoveVerbHandler) { Description = "Remove the currently selected TabListPage from the parent control." };
verbs.Add(addVerb);
verbs.Add(removeVerb);
}
return verbs;
}
}
private void AddVerbHandler(object sender, EventArgs e)
{
this.TabListControl.Add();
}
private void RemoveVerbHandler(object sender, EventArgs e)
{
//this.RemoveSelectedTabListPage();
}
public override void InitializeNewComponent(IDictionary defaultValues)
{
base.InitializeNewComponent(defaultValues);
this.TabListControl.Add();
this.TabListControl.Add();
}
}
所以这就是我所做的,但它不起作用。TabListControl.Add() 方法有效(我在运行时对其进行了测试,但我想要设计时支持)
我希望能够: - 控件应该在设计时使用 2 个 TabPages 进行初始化 - 在设计时添加/删除 TabPages - 在设计时切换 TabPages - 在设计时将控件添加到不同的 TabPages