Results 1 to 3 of 3

Thread: [RESOLVED] Finding WebBrowser on the selected Tab

  1. #1

    Thread Starter
    Fanatic Member Emcrank's Avatar
    Join Date
    Jan 2009
    Posts
    566

    Resolved [RESOLVED] Finding WebBrowser on the selected Tab

    I need to have the webbrowser on the selected tab dimmed, so like
    Code:
    Dim foundbrowser = TabControl1.SelectedTab.Controls.Find("WebBrowser", False)
    i know thats totally wrong but its just to show you what i kind of need, how do i do this? The only control on the selected tab is a webbrowser if that helps?
    Thanks in advance

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

    Re: Finding WebBrowser on the selected Tab

    First up, let's look at this statement:
    I need to have the webbrowser on the selected tab dimmed
    I know what you mean, but that statement actually makes no sense. First, you don't "dim" something. 'Dim' is the keyword used to declare a variable, just as 'Property' is the keyword used to declare a property and 'Sub' and 'Function' are used to declare methods. Second, you don't declare objects. You declare a variable and then assign an object to it. So, what you actually want to do is declare a variable and then assign the WebBrowser control from the selected TabPage to it. If you use the correct terminology then you have a far better chance of understanding what's actually happening and a far better chance of not making mistakes.

    As for the question, if the WebBrowser control is the only control on the TabPage then you can simply index the Controls collection and get the control at index 0. Given that that will return a Control reference, you should also cast the result as type WebBrowser:
    vb.net Code:
    1. Dim selectedBrowser = DirectCast(Me.TabControl1.SelectedTab.Controls(0), WebBrowser)
    That said, I would suggest that you define your own class and do that sort of thing internally. That's exactly what I did in my Tabbed Web Browser thread in the CodeBank. I suggest that you take a look.
    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

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