Prevent Multiple Tabs

8 posts, 1 answers
  1. RS
    RS avatar
    3 posts
    Member since:
    Apr 2014

    Posted 20 Apr 2014 Link to this post

    Hello!
    I have a radform with a button, when I click it, a usercontrol form opens in a tab inside the radpageview, all nice, but if I click the same button, the same usercontrol open in another tab.. so, the question is, how I can prevent this? for example instead of open the same tab, maybe it can focus to the tab that is already open with the usercontrol in it,

    this is the basic code for my button:

    1.RadPageViewPage page = new RadPageViewPage();
    2.UserControl1 uc = new UserControl1();
    3. 
    4.page.Text = "Page Test ";
    5.radPageView1.Pages.Add(page);
    6.page.Controls.Add(uc);
    7.radPageView1.SelectedPage = page;


    what type of if statement do I need here?

    Thanks!
    btw, amazing job with this .net toolbox! Thanks!
  2. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 21 Apr 2014 Link to this post

    Hi RS Bauer,

    Thank you for writing.

    In this case you can use the following if statement:
    private void radButton1_Click(object sender, EventArgs e)
    {
        if (radPageView1.Pages.Contains("Test Page"))
        {
            radPageView1.SelectedPage = radPageView1.Pages["Test Page"];
        }
        else
        {
            RadPageViewPage page = new RadPageViewPage();
            UserControl1 uc = new UserControl1();
            page.Name = "Test Page";
            page.Text = "Page Text";
            radPageView1.Pages.Add(page);
            page.Controls.Add(uc);
            radPageView1.SelectedPage = page;
        }
    }

    Please let me know if there is something else I can help you with. 
     
    Regards,
    Dimitar
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WinForms is Visual Studio 2017 Ready
  4. RS
    RS avatar
    3 posts
    Member since:
    Apr 2014

    Posted 21 Apr 2014 in reply to Dimitar Link to this post

    Nice! It works great! That's what I was looking for! Thank you very much Dimitar! Excellent support!
    and yes, there is something else, I need to run some code when my tab is close, so I'll need to "capture" the click of the close tab button of each page. I don't know if I have to create another thread for this question because is a different topic.. but anyways, thank you! (Y)
  5. Answer
    Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 22 Apr 2014 Link to this post

    Hello,

    Thank you for writing back.

    In this case you can use the PageRemoved/PageRemoving events. For example you can subscribe to the PageRemoved event like this:
    public Form1()
    {
        InitializeComponent();
        radPageView1.PageRemoved += radPageView1_PageRemoved;
    }
     
    void radPageView1_PageRemoved(object sender, RadPageViewEventArgs e)
    {
         
    }

    Also, I would like to kindly ask you in future, to separate the questions that are not related to each other in separate threads in order to make them easily accessible for the community.
     
    Do not hesitate to contact us if you have other questions.
     
    Regards,
    Dimitar
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. RS
    RS avatar
    3 posts
    Member since:
    Apr 2014

    Posted 23 Apr 2014 in reply to Dimitar Link to this post

    Thank you Dimitar! Works great! and again, sorry for the double topic!
  7. nestodre
    nestodre avatar
    5 posts
    Member since:
    Mar 2015

    Posted 11 Mar 2015 Link to this post

    I've got a problem like this too. I just want to expand only one page, so I did like your advise Dimitar.
    But the page still is not expanded, only the header is highlighted.
    I have scrolled all method of the RadPageViewPage but I didn't found any function can help me to expand the content of RadPageViewPage.
  8. nestodre
    nestodre avatar
    5 posts
    Member since:
    Mar 2015

    Posted 11 Mar 2015 Link to this post

    radPageView1.SelectedPage = radPageView1.Pages["Test Page"];
    I've tried to use this code with some different view modes, and I found that this line does not work with ExplorerBar view mode in RadPageView, but it works well with the others view mode.
    Can you suggest me some way to expand the page when I use ExplorerBar view mode?
    Thanks you,
  9. Stefan
    Admin
    Stefan avatar
    2890 posts

    Posted 12 Mar 2015 Link to this post

    Hello,

    I have answered your question in the other thread you have posted on the matter: http://www.telerik.com/forums/radpageviewpage-on-mouseover-event.

    Regards,
    Stefan
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for WinForms is Visual Studio 2017 Ready