C#-dev xtratabcontrol Dynamic Add tab and Close Tab method, there is a need for friends to refer to below.
Keep a record so you don't forget.
Add using Devexpress.xtratab;
Double-click the ListView to add the appropriate tabpage, and disallow repeated additions:
private void Listview_index_mousedoubleclick (object sender, MouseEventArgs e) { if (listview_index. Selecteditems.count > 0) { ListViewItem LVI = Listview_index. selecteditems[0];//Gets the selected item string name = Lvi. Text; Determines whether a foreach (Xtratabpage page in xtratabcontrol.tabpages) { if (page) has been created. Text = = name) { xtratabcontrol.selectedtabpage = page;//Display the page return; } } Increase TabPage xtratabpage xpage = new Xtratabpage (); Xpage. name = name; Xpage. Text = name; Xpage. Controls.Add (Listview_tec);//Add the Control xtraTabControl.TabPages.Add (xpage) to be added; Xtratabcontrol.selectedtabpage = xpage;//Display the page } }
To tabpage the Close button, set the Closepagebuttonshowmode property of the Xtratabcontrol to Inalltabpageheaders, or the Close button if you want the home page to appear:
Xtratab_index. Showclosebutton = devexpress.utils.defaultboolean.false;//Home does not show Close button
To add the Xtratabcontrol Closebuttonclick event:
private void Xtratabcontrol_closebuttonclick (object sender, EventArgs e)//Close Tab method { DevExpress.XtraTab.ViewInfo.ClosePageButtonEventArgs Earg = (DevExpress.XtraTab.ViewInfo.ClosePageButtonEventArgs ) e; String name = earg.page.text;//Gets the closed tab of the Text foreach (Xtratabpage Page in xtratabcontrol.tabpages)// Iterate through the same tab that gets and closes the text { if (page. Text = = name) { xtraTabControl.TabPages.Remove (page); Page. Dispose (); return;}}}
C#-dev Xtratabcontrol dynamically add tab and close tab methods