简体   繁体   中英

How to open new form in tab control winforms devexpress?

I need to open my Form in XtraTabControl. Help me how to open Forms on Tab Control ? Normally I open Forms in Panel Control I used

        panelControl1.Controls.Clear();
        var myForm = new NewForm();
        myForm.TopLevel = false;
        myForm.AutoScroll = true;
        panelControl1.Controls.Add(myForm);
        myForm.Show();

this code work for Panel Control but I need code to open form in Tab Control. Help me Thanks in Advance.

You easily can use the DevExpress UserControl. Make a class which extends from UserControl (you can also use Designer for it). Then your TabControl needs different TabPages which are your container. Then you can add your Form (UserControl) to the TabPage in same way like Panel.

To close a tab you can easily change the tab page to another one (which is empty or got other usercontrol). If the user should not come back you can use the visibility of each TabPage or the enable Property to handle this.

创建一个新的TabItem,将新窗体添加到创建的TabItem,最后将TabItem添加到TabControl。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM