RichTextBox.LinkClicked RichTextBox.LinkClicked RichTextBox.LinkClicked RichTextBox.LinkClicked Event


当用户在控件文本内的链接上单击时发生。Occurs when the user clicks on a link within the text of the control.

 event System::Windows::Forms::LinkClickedEventHandler ^ LinkClicked;
public event System.Windows.Forms.LinkClickedEventHandler LinkClicked;
member this.LinkClicked : System.Windows.Forms.LinkClickedEventHandler 
Public Custom Event LinkClicked As LinkClickedEventHandler 


下面的代码示例包含LinkClicked事件的事件处理程序。The following code example contains an event handler for the LinkClicked event. 事件处理程序在RichTextBox控件的文档内处理链接单击,并启动默认浏览器的实例( Process.Start使用方法),并显示已单击的链接的页面。The event handler processes link clicks within the document of a RichTextBox control and launches an instance of the default browser (using the Process.Start method), displaying the page for the link that was clicked. 此示例要求事件处理程序已连接到LinkClicked的事件。 RichTextBoxThis example requires that the event handler has been connected to the LinkClicked event for a RichTextBox.

   void Link_Clicked( Object^ sender, System::Windows::Forms::LinkClickedEventArgs^ e )
      System::Diagnostics::Process::Start( e->LinkText );
private void Link_Clicked (object sender, System.Windows.Forms.LinkClickedEventArgs e)
Private Sub Link_Clicked(sender As Object, e As System.Windows.Forms.LinkClickedEventArgs)
End Sub


可以为此事件创建事件处理程序,以处理已在控件内单击的链接。You can create an event handler for this event to process a link that has been clicked within the control. 通过使用提供给事件处理程序的信息,您可以确定在文档中单击的链接。Using the information provided to the event handler, you can determine which link was clicked in the document.


默认情况下,链接显示为文本并且不可单击。By default, links are displayed as text and are not clickable. 若要使它们可单击DetectUrls ,请true将属性设置为。To make them clickable set the DetectUrls property to true.

有关如何处理事件的详细信息,请参阅处理和引发事件For more information about how to handle events, see Handling and Raising Events.