Skip to main content
All docs
V23.2

GridOptionsBehavior.HyperlinkClickMode Property

Gets or sets whether and how hyperlinks in column and band headers are activated.

Namespace: DevExpress.XtraGrid.Views.Grid

Assembly: DevExpress.XtraGrid.v23.2.dll

NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

[DefaultValue(HyperlinkClickMode.Default)]
[XtraSerializableProperty]
public virtual HyperlinkClickMode HyperlinkClickMode { get; set; }

Property Value

Type Default Description
HyperlinkClickMode Default

A value that specifies whether and how hyperlinks in column and band headers are activated.

Available values:

Name Description
Default

The same as the None option.

CtrlClick

A hyperlink is activated on a mouse click when the CTRL key is pressed down.

Click

A hyperlink is activated on a mouse click.

None

Do not activate a hyperlink on a mouse pointer hover or click event.

Property Paths

You can access this nested property as listed below:

Object Type Path to HyperlinkClickMode
GridView
.OptionsBehavior .HyperlinkClickMode

Remarks

You can use HTML tags to insert hyperlinks in column headers (GridColumn.Caption) and band headers (GridBand.Caption). See OptionsView.AllowHtmlDrawHeaders for information on how to enable these tags.

The default behavior is to display hyperlinks, but restrict their activation on mouse events. Set the control’s HyperlinkClickMode property to one of the following values to allow users to activate hyperlinks:

  • Click value — A hyperlink is activated on a mouse click.
  • CtrlClick value — A hyperlink is activated on a mouse click when the CTRL key is pressed down.

Hyperlinks are never activated if the HyperlinkClickMode property is set to Default or None.

Handle the GridView.HyperlinkClick/BandedGridView.HyperlinkClick event to perform actions on hyperlink activation.

Example

The following example displays a hyperlink in the header of the ‘Change’ grid column. The GridView.HyperlinkClick event is handled to respond to a link click — which toggles the display mode of this column’s values.

Data Grid - Hyperlink Click

private void Form1_Load(object sender, EventArgs e) {
    BindingList<Ticker> list = new BindingList<Ticker>();
    list.Add(new Ticker() { Symbol = "AVR", Price = 101.4m, AbsoluteChange = 2.3m });
    list.Add(new Ticker() { Symbol = "RVA", Price = 414.1m, AbsoluteChange = 3.2m });
    list.Add(new Ticker() { Symbol = "ARBV", Price = 532.7m, AbsoluteChange = -18.0m });

    gridControl1.DataSource = list;
    gridView1.OptionsView.AllowHtmlDrawHeaders = true;
    gridView1.OptionsBehavior.HyperlinkClickMode = DevExpress.Utils.Drawing.HyperlinkClickMode.CtrlClick;
    gridView1.HyperlinkClick += GridView1_HyperlinkClick;

    gridView1.Columns["AbsoluteChange"].Visible = false;
    gridView1.Columns["PercentageChange"].Visible = false;

    GridColumn changeColumn = gridView1.Columns.AddUnbound("Change", typeof(decimal));
    changeColumn.Visible = true;
    changeColumn.OptionsColumn.AllowEdit = false;
    updateChangeColumnDisplayMode();

    gridView1.Columns["Price"].DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
    gridView1.Columns["Price"].DisplayFormat.FormatString = "c2";
}

bool usePercentageFormat = false;

private void GridView1_HyperlinkClick(object sender, DevExpress.XtraGrid.Views.Grid.GridHyperlinkClickEventArgs e) {
    if (e.Link == "toggle-display-mode") {
        usePercentageFormat = !usePercentageFormat;
        updateChangeColumnDisplayMode();
    }
}

void updateChangeColumnDisplayMode() {
    GridColumn column = gridView1.Columns["Change"];
    if (column == null) return;
    column.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
    if (usePercentageFormat) {
        column.Caption = "Change <a href=toggle-display-mode>(%)</a>";
        column.DisplayFormat.FormatString = "p2";
        // Display values from the PercentageChange field.
        column.UnboundExpression = "PercentageChange";
    }
    else {
        column.Caption = "Change <a href=toggle-display-mode>($)</a>";
        column.DisplayFormat.FormatString = "c2";
        // Display values from the AbsoluteChange field.
        column.UnboundExpression = "AbsoluteChange";
    }
}

public class Ticker {
    public string Symbol { get; set; }
    public decimal Price { get; set; }
    public decimal AbsoluteChange { get; set; }
    public decimal PercentageChange {
        get {
            if (Price > 0) return AbsoluteChange / Price;
            else return 0;
        }
    }
}
See Also