RichTextBox.LinkClicked Event
Occurs when the user clicks on a link within the text of the control.
[Visual Basic] Public Event LinkClicked As LinkClickedEventHandler [C#] public event LinkClickedEventHandler LinkClicked; [C++] public: __event LinkClickedEventHandler* LinkClicked;
[JScript] In JScript, you can handle the events defined by a class, but you cannot define your own.
Event Data
The event handler receives an argument of type LinkClickedEventArgs containing data related to this event. The following LinkClickedEventArgs property provides information specific to this event.
| Property | Description |
|---|---|
| LinkText | Gets the text of the link being clicked. |
Remarks
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.
For more information about handling events, see Consuming Events.
Example
[Visual Basic, C#, C++] The following example contains an event handler for the LinkClicked event. 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. This example assumes that the event handler has been connected to the LinkClicked event for a RichTextBox.
[Visual Basic] Protected Sub Link_Clicked(sender As Object, e As System.Windows.Forms.LinkClickedEventArgs) System.Diagnostics.Process.Start(e.LinkText) End Sub 'Link_Clicked [C#] protected void Link_Clicked (object sender, System.Windows.Forms.LinkClickedEventArgs e) { System.Diagnostics.Process.Start(e.LinkText); } [C++] protected: void Link_Clicked (Object* /*sender*/, System::Windows::Forms::LinkClickedEventArgs* e) { System::Diagnostics::Process::Start(e->LinkText); }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also
RichTextBox Class | RichTextBox Members | System.Windows.Forms Namespace