haro2x 0 Newbie Poster

Hello i have made a webbrowser using the webbrowser control in c#.
I have disabled the new window event, and now I want to get the url of the clicked link to open this url in current window.

Here is the code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Thunder
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        } 
        int i = 1;
        int w;
        WebBrowser br;
        string bd;
        private string adr;
        public List<string> h = new List<string>();

        private void br_Navigating(object sender, WebBrowserNavigatingEventArgs e)
        {
            progressBar1.Value = 80;
            label1.Text = "ucitavam";  
        }

        void brnw(object sender, CancelEventArgs e)
        {
            Form1 f1 = new Form1();
            f1.Show();
            e.Cancel = true;
        } 
 
        private void Form1_Load(object sender, EventArgs e)
        {
            progressBar1.Minimum = 0;
            progressBar1.Maximum = 100;
            bd = comboBox1.Text.ToString();
            br = new WebBrowser();
            w = 0;
            tabControl1.TabPages.Add ("tab " + i);
            tabControl1.SelectTab(i - 1);
            br.Name = "wb";
            br.Dock = DockStyle.Fill;
            tabControl1.SelectedTab.Controls.Add(br);
            i = i + 1;
            br.Navigate("http://www.google.ba");
            ((WebBrowser)tabControl1.SelectedTab.Controls[w]).DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(br_DocumentCompleted);
            ((WebBrowser)tabControl1.SelectedTab.Controls[w]).NewWindow += new System.ComponentModel.CancelEventHandler(brnw);
            ((WebBrowser)tabControl1.SelectedTab.Controls[w]).Navigating += new WebBrowserNavigatingEventHandler(br_Navigating);
            br.ScriptErrorsSuppressed = true;
        }

        private void noviTabToolStripMenuItem_Click(object sender, EventArgs e)
        {
            br = new WebBrowser();
            tabControl1.TabPages.Add("tab" + i);
            br.Dock = DockStyle.Fill;
            tabControl1.SelectTab(i - 1);
            tabControl1.SelectedTab.Controls.Add(br);
            comboBox1.Text = "";
            i = i + 1;
        }
       
        private void button1_Click(object sender, EventArgs e)
        {
            ((WebBrowser)tabControl1.SelectedTab.Controls[w]).Navigate(comboBox1.Text);
            adr = comboBox1.Text.ToString();
            label1.Text = "Ucitavam";
            progressBar1.Value = 50;
        }

        private void br_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            label1.Text = "Gotovo";
            Form1 f1 = new Form1();
            comboBox1.Text = ((WebBrowser)tabControl1.SelectedTab.Controls[w]).Url.ToString();
            progressBar1.Value = 0;
            h.Add(((WebBrowser)tabControl1.SelectedTab.Controls[w]).Url.ToString());
        }
        
        private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                comboBox1.Text = ((WebBrowser)tabControl1.SelectedTab.Controls[w]).Url.ToString();
            }
            catch (ArgumentOutOfRangeException)
            {
            }
            catch (NullReferenceException)
            {
            }
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            ((WebBrowser)tabControl1.SelectedTab.Controls[w]).Navigate("http://www.google.ba");
            comboBox1.Text = "http://www.google.ba";
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            ((WebBrowser)tabControl1.SelectedTab.Controls[w]).GoBack();
        }

        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            ((WebBrowser)tabControl1.SelectedTab.Controls[w]).GoForward();
        }

        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            ((WebBrowser)tabControl1.SelectedTab.Controls[w]).Stop();
        }

        private void toolStripButton5_Click(object sender, EventArgs e)
        {
            ((WebBrowser)tabControl1.SelectedTab.Controls[w]).Refresh();
        }
        private void button2_Click(object sender, EventArgs e)
        {
            if (tabControl1.TabPages.Count == 1)
                MessageBox.Show("Nemozes ukloniti taj tab !");
            else if (tabControl1.TabPages.Count > 1)
            {
                tabControl1.TabPages.Remove(tabControl1.SelectedTab);
                i = i - 1;
                tabControl1.SelectTab(i - 2);
            }
        }

        private void noviProzorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form1 f1 = new Form1();
            f1.Show();
        }

        private void novaLokacijaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            comboBox1.SelectAll();
        }

        private void ugasiProzorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void izadjiToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void tabControl1_Selected(object sender, TabControlEventArgs e)
        {
            try
            {
                comboBox1.Text = ((WebBrowser)tabControl1.SelectedTab.Controls[w]).Url.ToString();
            }
            catch (ArgumentOutOfRangeException)
            {
            }
            catch (NullReferenceException)
            {
            }
        }

        private void oThunderBirduToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form2 f2 = new Form2();
            f2.Show();
        }

        private void facebookSelectAllFriendsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            comboBox1.Text = "javascript:fs.select_all()";
            ((WebBrowser)tabControl1.SelectedTab.Controls[w]).Navigate(comboBox1.Text.ToString());
        }

        private void historijaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form3 f3 = new Form3();
            f3.Show();
            timer1.Start();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            foreach (Form f in Application.OpenForms)
            {
                if (f.Name == "Form3")
                {
                    Form3 f3 = (Form3)f;
                    comboBox1.Text = f3.ha;
                }
            }
        }

        private void comboBox1_Click(object sender, EventArgs e)
        {
            timer1.Stop();
        }
    }
}