Web Browser in Rotator?

5 posts, 0 answers
  1. Richard Thurgood
    Richard Thurgood avatar
    26 posts
    Member since:
    Nov 2007

    Posted 16 Jul 2008 Link to this post

    Hi guys,
    I'd like to dynamically create and load a web browser control in the rotator.  The web browser control will be used to show either a PDF or an image depending on the data I have stored. 

    foreach(DataRow dr in MyTable.Rows)
    {
        //todo: create browser control

        if (IsPDF)
       {
            //todo: load PDF (from field in datarow) into browser control
        }
        else
        {
            //todo: load IMAGE (from field in datarow) into browser control
        }

        //todo: load browser control into radRotator
    }
  2. Richard Thurgood
    Richard Thurgood avatar
    26 posts
    Member since:
    Nov 2007

    Posted 16 Jul 2008 Link to this post

    Okay, perhaps I was premature in asking. The answer is "YES", you can add a browser control to a radRotator.

    I whipped up something real quick to illustrate......

    private void PopulateBrowserControl()
    {
     for (int i = 1; i < 10; i++)
     {
      WebBrowser browser = new WebBrowser();
      browser.Navigate("about:blank");
      while (browser.ReadyState != WebBrowserReadyState.Complete)
      {
       Application.DoEvents();
      }
      browser.Document.Body.InnerHtml = "Page " + Convert.ToString(i);
      PopulateRotator(browser);
     }
     radRotator1.Goto(0);
    }

    private void PopulateRotator(WebBrowser browser)
    {
     radRotator1.Items.Add(new RadHostItem(browser));
    }

     

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Mike
    Admin
    Mike avatar
    640 posts

    Posted 17 Jul 2008 Link to this post

    Hi Richard,

    It is great you found out the solution alone. Allow me one addition, though. You can also use the specialized RadWebBrowserElement, which inherits RadHostItem and wraps up the WebBrowser control for you. The advantages consist in the ability to add this item in RadRotator, RadCarousel and other controls using the Visual Studio designer.

    Don't hesitate to contact us if you have further questions.

    Sincerely yours,
    Mike
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. Richard Thurgood
    Richard Thurgood avatar
    26 posts
    Member since:
    Nov 2007

    Posted 17 Jul 2008 Link to this post

    That's awesome. Can you retro-fit my example to show how to use it?
  6. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 17 Jul 2008 Link to this post

    Hi Richard,

    As Mike said, the only advantage you will get by using RadWebBrowserElement is that you can add it at design-time in the RadRotator's Items collection, using the Visual Studio designer. However, since you are using the programmatic approach, which is good enough in this case, you do not need the RadWebBrowserElement.

    If you have additional questions, feel free to contact me.

    Regards,
    Nikolay
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top
UI for WinForms is Visual Studio 2017 Ready