blah blah blah is here! blah blah » Close

up0down
link

Hi,

I have a dataGridView and a webBrowser on a form. I have an Access database associated with the dataGridview. I have a list of URLs in one column and I want webbrowser to go to the URL when I click the cell that contains the URL on the dataGridView. Or I might have a button so that when I click on a cell and click the button, webbrowser will go to that URL. Is this possible?

Thanks in advance.

last answered one year ago

1 answers

link

yes it is, if you are talking about a grid view, try setting an event handler for cellselected so if the cell is a url cell the url is copied form the value of the selected cell to the webbrowser control.

ademmeda
108

So, I am trying something like: private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { webBrowser1.Navigate(new Uri(dataGridView1.SelectedCell.ToString())); } But it does not accept "SelectedCell", what should I write instead?

vulpes
17279

Try: webBrowser1.Navigate(dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString());

ademmeda
108

Well, I guess you have an answer to all my questions, the code you gave worked as I needed. Thanks again :)

Feedback