Reputation: 980
I am new to winforms.I cannot post any code as I am using a designer for my gridview in winforms. I have 2 columns. In 1 column links name is there and other column which is hidden has link names actual link. E.g if in column 1 Google is written so, there is 2nd column(hidden) which has http://www.google.com in it. When I click the datagridview cell with links name, the link should open in browser. Is there a way to do it. I googled it but all I got is this. Please help.
Upvotes: 0
Views: 4686
Reputation: 9576
All you need to do is to add an OnClick
handler to your row and from there start a new process which will launch a browser with the url:
private void OnClick(object sender, RowEventArgs e) // I don't know exactly how the event handlers signature is
{
// Get the url from the row
var url = e.Row.Columns[1].Value;
Process.Start(url);
}
EDIT
The code above will start the default browser. If you want to start a non-default browser i.e. IE (pun intended) you'll have to use an overload of Process.Start
and pass it the path to executable and the url like this:
Process.Start("iexplore.exe", url);
Upvotes: 5