C# Listview Question

Discussion in 'Programming' started by ademmeda, Mar 22, 2010.

  1. #1
    Hi,

    I am working on a small application which has a listview and webbrowser control on it. I have a list of URLs in the first column of the listview. I want the webbrowser navigate to the URL when I click on that item in the listview. Is this possible?

    I am trying something like the following but cannot figure it out.

    private void listView1_SelectedIndexChanged(object sender, EventArgs e)
            {
               webBrowser1.Navigate(new Uri(listView1.SelectedItem.ToString()));
            }
    Code (markup):
     
    ademmeda, Mar 22, 2010 IP
  2. EgyptGuy

    EgyptGuy Peon

    Messages:
    167
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Easy ! enjoy the line mate ;]

    
     private void listView1_SelectedIndexChanged(object sender, EventArgs e)
            {
                try
                {
                    webBrowser1.Navigate(listView1.SelectedItems[0].Text, false);
                }
                catch { };
            }
    
    Code (markup):
    P/S: Don't forget turn the multi selection property to false
     
    Last edited: Mar 23, 2010
    EgyptGuy, Mar 23, 2010 IP