RichTextBox.LinkClicked 事件

定义

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

public:
 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. 此示例要求事件处理程序已连接到 RichTextBoxLinkClicked 事件。This example requires that the event handler has been connected to the LinkClicked event for a RichTextBox.

private:
   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)
{
   System.Diagnostics.Process.Start(e.LinkText);
}
Private Sub Link_Clicked(sender As Object, e As System.Windows.Forms.LinkClickedEventArgs)
   System.Diagnostics.Process.Start(e.LinkText)
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 属性设置为 trueTo make them clickable set the DetectUrls property to true.

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

适用于

另请参阅