RepositoryItemHyperLinkEdit.Caption Property

Gets or sets the caption string displayed in the edit box.

Namespace: DevExpress.XtraEditors.Repository

Assembly: DevExpress.XtraEditors.v20.1.dll

Declaration

[DXCategory("Appearance")]
[DefaultValue("")]
public virtual string Caption { get; set; }
<DXCategory("Appearance")>
<DefaultValue("")>
Public Overridable Property Caption As String

Property Value

Type Default Description
String

String.Empty

A string value specifying the hyperlink editor's caption.

Remarks

By default, the Caption property value is an empty string. In this instance, the editor displays the textual representation of the edit value in the edit box. The edit value specifies the command of the hyperlink editor. The command is obtained from the edit value by calling the ToString method. See the BaseEdit.Text property to get the hyperlink command.

In some cases, it may be useful to display a different text instead of the command. For instance, you may not specify want to specify any command, but handle the RepositoryItemHyperLinkEdit.OpenLink event to perform your own processing when the user activates hyperlink functionality. Setting Caption to a non-empty string enables you to override the default representation of the hyperlink command displayed in the edit box.

Examples

The following example shows how to implement hyperlink functionality by handling the HyperLinkEdit.OpenLink event. The hyperlink command is not required by this example.

Instead we handle the HyperLinkEdit.OpenLink event, which occurs before activating the hyperlink, and then run a custom command. In this example, we open Explorer displaying the path for the current executable file. The OpenLinkEventArgs.Handled property of the event parameter is set to true. This disables subsequent default processing.

To specify the display text for the editor, the RepositoryItemHyperLinkEdit.Caption property is set to a specific string ("Show Startup Directory"). If RepositoryItemHyperLinkEdit.Caption contains a non-empty string, the editor will always display this value in the edit box. This allows you to store specific data in the edit value while representing them using the RepositoryItemHyperLinkEdit.Caption string.

The following image shows a hyperlink editor with a customized caption and Explorer activated by the editor:

Hyperlink_example_ShowStart

hyperLinkEdit1.Properties.Caption = "Show Startup Directory";
// ...
void hyperLinkEdit1_OpenLink(object sender, DevExpress.XtraEditors.Controls.OpenLinkEventArgs e) {
    System.Diagnostics.Process process = new System.Diagnostics.Process();
    process.StartInfo.FileName = Application.StartupPath;
    process.StartInfo.Verb = "explore";
    process.StartInfo.WindowStyle = (sender as HyperLinkEdit).Properties.BrowserWindowStyle;
    process.Start();
    e.Handled = true;
}
See Also