I am developing one win application IN C# which makes use of WebBrowser control.
I am passing the url in a text box and the page is getting displayed in the web browser control.Till this its fine.Whn ever a link is clicked inside the webbrowser control it is opening in the same page.
Is there any way such that the clicked links inside a webbrowser control should open in a new tab with the tab having the page title.Imean dynamically open in a new webbrowser control...
I in fact tried this code in the navigating event of webbrowser control.But it is also opening a new tab and inthe browser which is newly created is having the message "action cancelled".
The clicked url is getting opened in the 1st browser control...
Here is the piece of code i tried ...
Please help ...
void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
navigatedUrl = webBrowser1.StatusText.ToString();
int tab_count = 0;
string tabName;
tab_count = tabControl1.Controls.Count;
tabName = "TabPage" + ++tab_count;
TabPage tabNew = new TabPage();
tabNew.Location = new System.Drawing.Point(4, 24);
tabNew.Padding = new System.Windows.Forms.Padding(3);
tabNew.Size = new System.Drawing.Size(800, 517);
tabNew.TabIndex = 0;
tabNew.Text = tabName;
tabNew.UseVisualStyleBackColor = true;
tabControl1.Controls.Add(tabNew);
tabNew.Name = tabName;
string webName = "webBrowser" + tab_count;
WebBrowser webNew = new WebBrowser();
webNew.Dock = System.Windows.Forms.DockStyle.Fill;
webNew.Location = new System.Drawing.Point(3, 3);
webNew.MinimumSize = new System.Drawing.Size(20, 20);
webNew.Name = webName;
webNew.Size = new System.Drawing.Size(794, 511);
webNew.TabIndex = 0;
webNew.AllowNavigation = true;
tabNew.Controls.Add(webNew);
webNew.Navigate(navigatedUrl );
}
--------------------------------------------------------------------------------
Thanks in advance ,
Bryan

New Topic/Question
Reply




MultiQuote




|