Results 1 to 7 of 7

Thread: [RESOLVED] Help : TabControl (Contained Controls )

  1. #1

    Thread Starter
    Addicted Member Ashraf Alshahawy's Avatar
    Join Date
    May 2007
    Location
    Egypt
    Posts
    241

    Resolved [RESOLVED] Help : TabControl (Contained Controls )

    Hi everyone ....

    I'm using a TabCotrol in my project , and I want to load as many tabs pages as I

    need with a PDF control within each tab page

    so I used this code :

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

    Dim NewAdobePage As New AxAcroPDFLib.AxAcroPDF
    Dim tb As New TabPage

    TabControl.TabPages.Add(tb)
    tb.Controls.Add(NewAdobePage)

    End Sub

    and now I want to use OpenFileDialog control to load PDF files into any of the

    already opened AxAcroPDF controls , How ???

    Thanks in advance
    Some times when you make a step forward ...You can't get back. Be sure where you make your steps.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Help : TabControl (Contained Controls )

    Do you know how to open a file in one of those controls ordinarily? If so then you open a file in one of these exactly the same way. To get a reference to the control in the first place you would get the appropriate TabPage, get its first control and cast it, e.g.
    vb.net Code:
    1. Dim pdfViewer = DirectCast(myTabControl.SelectedTab.Controls(0), AxAcroPDFLib.AxAcroPDF)
    That said, I'd suggest that you create your own class that inherits TabPage, adds the control itself and then exposes it via a dedicated property. If you follow the CodeBank link in my signature you can check out my Tabbed Web Browser thread, where I've done exactly that but with a WebBrowser control.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Addicted Member Ashraf Alshahawy's Avatar
    Join Date
    May 2007
    Location
    Egypt
    Posts
    241

    Re: Help : TabControl (Contained Controls )

    Many thanks for your help ... I downloaded your project to practice your idea but after

    my VB.net 2008 transferred it , it gives me an error message :

    Could not find type 'TabbedWebBrowser.WebBrowserTabControl'. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built.

    What should I do .... Many thanks in advance.
    Some times when you make a step forward ...You can't get back. Be sure where you make your steps.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Help : TabControl (Contained Controls )

    You can't just copy and paste code from my project that uses types that I defined. I defined a class that inherited TabPage and created its own WebBrowser. If you want to follow the same principle then you need to define your own class that inherits TabPage and creates its own AxAcroPDF. Likewise, I created a custom TabControl that makes using those custom TabPages easier. If you want to use the same principle then you have to, again, define your own class.

    Don't copy and paste any code from my project. Read the code and run the project in the debugger if you want until you understand the principles it's implementing, then write your own code that implements those same principles in a way that is useful to you. Obviously a WebBrowserTabControl is of no use to you because you aren't using any WebBrowsers.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Addicted Member Ashraf Alshahawy's Avatar
    Join Date
    May 2007
    Location
    Egypt
    Posts
    241

    Re: Help : TabControl (Contained Controls )

    I hope that I'm not bothering you , but I downloaded your project entirely , and I faced this

    problem before and I'd like to know what is going wrong .... Do I have to add tools to the

    project ( Reference ) ??

    - And for your first answer :
    im pdfViewer = DirectCast(myTabControl.SelectedTab.Controls(0), AxAcroPDFLib.AxAcroPDF)

    it works fine for me , many thanks for that code .
    Some times when you make a step forward ...You can't get back. Be sure where you make your steps.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Help : TabControl (Contained Controls )

    I'm not quite sure what you're asking. I just downloaded the Tabbed Web Browser project I attached to that CodeBank thread and when I opened in in VS 2008 it upgraded and built without issue and I can see the WebBrowserTabControl class in the Solution Explorer so it's obviously defined.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Addicted Member Ashraf Alshahawy's Avatar
    Join Date
    May 2007
    Location
    Egypt
    Posts
    241

    Re: Help : TabControl (Contained Controls )

    Many thanks .... and after I restarted my computer and reopened your project , It works

    like a charm ... perhaps it's system error , or maybe I'm using Google Chrome as a default

    web browser. And I'm reading your code trying to find my needs.

    P.S : What does DirectCast function exactly do ?? is it return a reference or what ??

    Many thanks in advance
    Some times when you make a step forward ...You can't get back. Be sure where you make your steps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width