Hàm tạo TabContent:
Sau khi tạo hàm, muốn add bằng cách tạo UserControl và dùng câu lệnh sau để gọi tab:#region /************* them tab****************/private void addNewTab(string strTabName, UserControl ucContent){DevExpress.XtraTab.XtraTabPage newTabPage = new DevExpress.XtraTab.XtraTabPage();newTabPage.Name = "xtraTabName" + strTabName;//kiem tra ton taiforeach (DevExpress.XtraTab.XtraTabPage tabpage in tabContent.TabPages){if (tabpage.Name == newTabPage.Name){tabContent.SelectedTabPage = tabpage;return;}}//them tab moitabContent.TabPages.Add(newTabPage);tabContent.SelectedTabPageIndex = tabContent.TabPages.Count - 1;//tao thuoc tinh cho tab moinewTabPage.Appearance.PageClient.BackColor = System.Drawing.Color.Cyan;newTabPage.Appearance.PageClient.Options.UseBackColor = true;//tao thuoc tinh cho UCcontentucContent.Dock = DockStyle.Fill;newTabPage.Controls.Add(ucContent);newTabPage.ShowCloseButton = DevExpress.Utils.DefaultBoolean.True;newTabPage.Size = new System.Drawing.Size(929, 458);newTabPage.Text = strTabName;}private void tabContent_CloseButtonClick(object sender, EventArgs e){if (tabContent.SelectedTabPageIndex != 0){try{int index = tabContent.SelectedTabPageIndex;tabContent.TabPages.RemoveAt(index);tabContent.SelectedTabPageIndex = index - 1;}catch (ThreadInterruptedException){Console.WriteLine("[{0}] Interrupted! Cleaning up...", Thread.CurrentThread.Name);}}}#endregion
SinhDayNhiPhan uc = new SinhDayNhiPhan();
addNewTab("BT sinh dãy nhị phân", uc);Kết quả: