Original Post
Okay, I'm really somewhat new to .NET and WinForms but I couldn't find an answer anywhere, so maybe somebody can enlighten me here... I have a TabControl that starts out with no tabpages. I also have a button, if you click it a new tab with a WebBrowser control in it is created like this: This works fine. Now, when another event is fired I want to retrieve the WebBrowser control from the tab that is currently selected. This is what I have: I just want to retrieve that specific control but I can't seem to find any way. I know that "tabControl->SelectedTab->Controls["webBrowser"]" IS a webBrowser control at runtime (if I try to access its "text" property it crashes and tells me that WebBrowser doesn't have a "text") but I can't seem to find a way to convert that general control structure into a specific WebBrowser one. Is there a way? Any help is appreciated.
tabControl->TabPages->Add ( "tab", "Empty Tab" );
WebBrowser^ webBrowser = gcnew WebBrowser ( );
webBrowser->Name = "webBrowser";
webBrowser->AutoSize = true;
webBrowser->Dock = DockStyle::Fill;
tabControl->TabPages["tab"]->Controls->Add ( webBrowser );
WebBrowser^ webBrowser = gcnew WebBrowser ( );
webBrowser = tabControl->SelectedTab->Controls["webBrowser"];