日期:2014-05-20  浏览次数:20779 次

winform 关于tabcontrol控件。满意给高分!
我要的效果是不管我点tabpage1还是tabpage2 或者更多tabpage 都显示 tabPage1 的内容,该怎么做 希望附上代码!
------解决方案--------------------
内容不放在tabpage里,放到外层的Panel中,覆盖在tabpage上面
  
*****************************************************************************
签名档: http://feiyun0112.cnblogs.com/
------解决方案--------------------
1楼+1,省时又省力;
------解决方案--------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            tp = tabControl1.SelectedTab;
        }

        private TabPage tp;

        private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            foreach (Control c in tp.Controls.Cast<Control>().ToList())
            {
                tp.Controls.Remove(c);
                tabControl1.SelectedTab.Controls.Add(c);
            }
            tp = tabControl1.SelectedTab;
        }
    }
}

------解决方案--------------------
思路就是把控件从上一个页面一个一个搬过来。