[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
Re: Finding WebBrowser on the selected Tab
First up, let's look at this statement:
Quote:
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:
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.
Re: Finding WebBrowser on the selected Tab