C #-dev xtratabcontrol dynamically adds the tab and closes the tab method. For more information, see.
Record it to avoid forgetting it later
Add using devexpress. xtratab;
Double-click listview to add the corresponding tabpage. Do not Add the following items again:
Private void listview_index_mousedoubleclick (Object sender, mouseeventargs e) {If (latency> 0) {listviewitem LVI = listview_index.selecteditems [0]; // obtain the selected string name = LVI. text; // determine whether foreach (xtratabpage in xtratabcontrol) has been created. tabpages) {If (page. TEXT = Name) {xtratabcontrol. selectedtabpage = page; // display the return;} // Add tabpage xtratabpage xpage = new xtratabpage (); xpage. name = Name; xpage. TEXT = Name; xpage. controls. add (listview_tec); // Add the control xtratabcontrol to be added. tabpages. add (xpage); xtratabcontrol. selectedtabpage = xpage; // display this page }}
To display the close button on the tabpage, set the closepagebuttonshowmode attribute of xtratabcontrol to inalltabpageheaders. If you want to display the close button on the home page:
Xtratab_index.showclosebutton = devexpress. utils. defaultboolean. False; // The close button is not displayed on the homepage.
Add the closebuttonclick event of xtratabcontrol:
Private void xtratabcontrol_closebuttonclick (Object sender, eventargs e) // close the tab method {devexpress. xtratab. viewinfo. closepagebuttoneventargs earg = (devexpress. xtratab. viewinfo. closepagebuttoneventargs) E; string name = earg. page. text; // obtain the text foreach (xtratabpage in xtratabcontrol) of the closed tab. tabpages) // retrieve the text {If (page. TEXT = Name) {xtratabcontrol. tabpages. remove (PAGE); page. dispose (); Return ;}}}
C #-dev xtratabcontrol: dynamically add and disable tabs