开发者

C# - Have your desktop application open the system browser in a specific webpage [duplicate]

This question already has answers here: 开发者_如何学运维 Closed 12 years ago.

Possible Duplicate:

Open a URL from Windows Forms

Hello!

I have a C# desktop application and I want to be able to have a link in it that will open a new browser window/tab (on the system default browser) in a specific webpage. I've looked for this in the web but haven't found anything yet. Any help?? thanks...


If you Process.Start the url, that should do the same as ShellExecute, which is the way you'd do it in native code.

You could use a LinkLabel from the toolbox, to get the link onto the form with the proper behaviour. Example code here.

Simpler version:

  private void Form1_Shown (object sender, EventArgs e)
  {
     linkLabel1.Links.Add (0, 7, "http://bobmoore.mvps.org/");
     linkLabel1.LinkClicked += new LinkLabelLinkClickedEventHandler(linkLabel1_LinkClicked);
  }

  private void linkLabel1_LinkClicked (object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
  {
     this.linkLabel1.Links[linkLabel1.Links.IndexOf (e.Link)].Visited = true;
     string target = e.Link.LinkData as string;

     System.Diagnostics.Process.Start (target);
  }


You should use a LinkLabel control and Process.Start.
Here is an example how to use it.

PS. You really should start accepting answers if you want to get help in the future.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜