How to display a RepositoryItemHyperLinkEdit control inside a DevExpress GridControl

Ranjan Panigrahi picture Ranjan Panigrahi · Jan 22, 2013 · Viewed 8.3k times · Source

I have a DevExpress GridControl in my current WinForms application. I need to display a hyperlink control (RepositoryItemHyperLinkEdit) in a column. I have added the RepositoryItemHyperLinkEdit via designer, but when I am running the application, hyperlink is not displaying.
Like to display buttons we are using:

repositoryItemButtonEdit1.Buttons[0].Kind = DevExpress.XtraEditors.Controls.ButtonPredefines.Glyph;
repositoryItemButtonEdit1.Buttons[0].Caption = "Get Sql Query";

So please tell me what I will write to display hyperlink in a column.

Answer

DmitryG picture DmitryG · Jan 22, 2013

You can use the following code to display hyperlink in grid column:

GridColumn hyperLinkColumn = gridView1.Columns["Hyperlink"];
//...
RepositoryItemHyperLinkEdit hyperLinkEdit = new RepositoryItemHyperLinkEdit();
hyperLinkColumn.ColumnEdit = hyperLinkEdit; // this line associated hyperlink with column
hyperLinkEdit.OpenLink += hyperLinkEdit_OpenLink;
//...
void hyperLinkEdit_OpenLink(object sender, OpenLinkEventArgs e) {
    MessageBox.Show("HyperLinkEdit clicked!");
}

If you want to display aditional button in the same column you can use the following approach:

hyperLinkEdit.Buttons[0].Kind = ButtonPredefines.Glyph;
hyperLinkEdit.Buttons[0].Caption = "Get SQL Query";
hyperLinkEdit.ButtonClick += hyperLinkEdit_ButtonClick;
hyperLinkColumn.ShowButtonMode = ShowButtonModeEnum.ShowAlways; // always display button in this column
//...
void hyperLinkEdit_ButtonClick(object sender, ButtonPressedEventArgs e) {
    MessageBox.Show("HyperLinkEdit's button clicked!");
}