在RichTextBox控制元件中新增超連結文字
阿新 • • 發佈:2018-12-20
實現效果:
知識運用:
RichTextBox控制元件的AppendText方法
public void AppendText{string textData} //向控制元件中新增文字內容
和Process類的Start方法
public static Process Start(string fileName,string arguments) //啟動一個程序資源
//引數分別對應 (要在程序中執行的程序的檔名稱 啟動程序時傳遞的命令列引數)
實現程式碼:
private void button1_Click(object sender, EventArgs e) { rtbox_HyperLink.AppendText(@" 谷歌:https://www.google.com 網易:https://www.163.com 百度:https://www.baidu.com 奇虎:https://www.so.com"); } private void rtbox_HyperLink_LinkClicked(object sender, LinkClickedEventArgs e) { Process.Start("iexplore.exe",e.LinkText); }