Usercontrol选项卡

时间:2013-01-06 22:52:49

标签: c# dynamic-usercontrols

我为一个标签创建了一个简单的用户控件,但是当我调用它时它显示的非常小并且可以将其调整为任何大小,这里是代码。我错了什么?

public class tabController : UserControl
{
    public tabController(string id)
    {
        InitializeComponent(id);
    }
    public void InitializeComponent(string id)
    {
        TabControl tabControl;
        TabPage tab1, tab2, tab3, tab4, tab5, tab6, tab7, tab8, tab9, tab10;
        tabControl = new TabControl();
        tabControl.Location = new Point(500, 250);
        tabControl.Size = new Size(500, 500);
        tabControl.ClientSize = new Size(500, 500);
        var xmlData = Binder.fSelect.GetData(3, 1, 1, 0, "", "", 0, 25);

    StringReader sr = new StringReader(xmlData);
    //dsData.ReadXml(xmlData);
    //string xmlString = sw.ToString();
    DataSet ds = new DataSet();
    ds.ReadXml(sr);

    int i = 0;
    for (i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
    {
        //string v = ds.Tables[0].Rows[i].ItemArray[2].ToString();
        if ((ds.Tables[0].Rows[i].ItemArray[4].ToString()) == "114")
        {
            if (i == 0)
            {
                tab1 = new TabPage(ds.Tables[0].Rows[i].ItemArray[1].ToString());
                tabControl.TabPages.Add(tab1);
            }
        }
    } 
    tabControl.Dock = DockStyle.Fill;
    this.Controls.Add(tabControl);

1 个答案:

答案 0 :(得分:0)

在调用时,请尝试将用户控件的Dockstyle属性用于Dockstyle.Fill