C#使用自定义TabPage更改TabControl中的默认TabPage

C#使用自定义TabPage更改TabControl中的默认TabPage,c#,winforms,tabcontrol,tabpage,C#,Winforms,Tabcontrol,Tabpage,我创建了一个自定义TabControl和一个自定义TabPage,如下所示: 自定义TabControlcode: public class MyCustomTabControl : TabControl { //Some Custom Properties public MyCustomTabControl () : base() { base.Width = 200; base.Height = 100; } } 自定义选项卡

我创建了一个自定义
TabControl
和一个自定义
TabPage
,如下所示:

自定义
TabControl
code:

public class MyCustomTabControl : TabControl
{
   //Some Custom Properties

   public MyCustomTabControl () : base()
    {
        base.Width = 200;
        base.Height = 100;

    }
}
自定义
选项卡页面

public class MyCustomTabPage : TabPage
{
    //Some Custom Properties

    public MyCustomTabPage() : base()
    {                     
        this.BackColor = System.Drawing.Color.Transparent;
    }
}

如何才能在表单中添加自定义控件
MyCustomTabControl
时,添加名为
MyCustomTabPage
的自定义
TabPage
。目前,它正在从windows添加
选项卡页面。

您需要执行一些步骤,首先定义一个类,例如
MyCustomTabCollection
,并为您的
MyCustomTabCollection
类实现所有三种接口方法,然后将
MyCustomTabControl
上的
MyCustomTabCollection
实例声明为
public
属性

实现接口

实施所有方法

声明您的CustomTabPageCollection


如果还有问题,请告诉我。

您需要执行一些步骤,首先定义一个类,例如
MyCustomTabCollection
,并为您的
MyCustomTabCollection
类实现所有三种接口方法,然后将
MyCustomTabControl
上的
MyCustomTabCollection
实例声明为
public
属性

实现接口

实施所有方法

声明您的CustomTabPageCollection


如果还有问题,请告诉我。

您不能使用设计器,必须使用代码。在InitializeComponent()调用之后,在表单的构造函数中编写它。当心TabControl。你不能用设计器,你必须用代码。在InitializeComponent()调用之后,在表单的构造函数中编写它。当心那个TabControl。
public class MyCustomTabPageCollection : IList, ICollection, IEnumerable
{
    // implement all three interfaces
}
public object this[int index] { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }

public bool IsReadOnly => throw new NotImplementedException();

public bool IsFixedSize => throw new NotImplementedException();

public int Count => throw new NotImplementedException();

public object SyncRoot => throw new NotImplementedException();

public bool IsSynchronized => throw new NotImplementedException();

public int Add(object value)
{
    throw new NotImplementedException();
}

public void Clear()
{
    throw new NotImplementedException();
}

public bool Contains(object value)
{
    throw new NotImplementedException();
}

public void CopyTo(Array array, int index)
{
    throw new NotImplementedException();
}

public IEnumerator GetEnumerator()
{
    throw new NotImplementedException();
}

public int IndexOf(object value)
{
    throw new NotImplementedException();
}

public void Insert(int index, object value)
{
    throw new NotImplementedException();
}

public void Remove(object value)
{
    throw new NotImplementedException();
}

public void RemoveAt(int index)
{
    throw new NotImplementedException();
}
public class MyCustomTab : TabControl
{
    public MyCustomTabPageCollection TabPages { get; set; }

    public MyCustomTab() : base()
    {
        base.Width = 200;
        base.Height = 100;

    }
}