简体   繁体   English

如何在DevExpress GridControl中显示RepositoryItemHyperLinkEdit控件

[英]How to display a RepositoryItemHyperLinkEdit control inside a DevExpress GridControl

I have a DevExpress GridControl in my current WinForms application. 我在当前的WinForms应用程序中有一个DevExpress GridControl。 I need to display a hyperlink control (RepositoryItemHyperLinkEdit) in a column. 我需要在列中显示超链接控件(RepositoryItemHyperLinkEdit)。 I have added the RepositoryItemHyperLinkEdit via designer, but when I am running the application, hyperlink is not displaying. 我已经通过设计器添加了RepositoryItemHyperLinkEdit,但是当我运行应用程序时,超链接没有显示。
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. 所以请告诉我我要编写什么来显示列中的超链接。

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: 如果要在同一列中显示aditional按钮,可以使用以下方法:

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!");
}

You didn't mentioned that you've set up the ColumnEdit property of the column to the repository item. 您没有提到您已将列的ColumnEdit属性设置为存储库项。 If you haven't: 如果你还没有:

存储库项目

Note that you may have to use the gridView_MouseUp event in order to catch the click event without waiting that the grid give the focus to the cell. 请注意,您可能必须使用gridView_MouseUp事件才能捕获click事件,而无需等待网格将焦点放在单元格上。

gridColumn.ColumnEdit = new RepositoryItemHyperLinkEdit();
gridColumn.OptionsColumn.ReadOnly = true;
gridColumn.OptionsColumn.AllowEdit = false;

gridView.MouseUp += gridView_MouseUp;

private void gridViewDesk_MouseUp(object sender, MouseEventArgs e)
{
    GridView gridView = (GridView) sender;
    if (e.Button == MouseButtons.Left && e.Clicks == 1)
    {
        GridHitInfo hitInfo = gridView.CalcHitInfo(e.Location);
        if (hitInfo.InRowCell && hitInfo.Column == this.gridColumn)
        {
            MessageBox.Show("Click " + hitInfo.RowHandle);
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Devexpress GridControl中的EditTemplate中获取控件的引用 - How to get reference of control inside EditTemplate in Devexpress GridControl 如何将devexpress defaultLookAndFeel组件放入devexpress网格控件中? - How can I put a devexpress defaultLookAndFeel Component inside of a devexpress gridcontrol? 如何使devexpress gridcontrol的指示器将文本显示为粗体 - How to make devexpress gridcontrol's indicator display text bold 如何在devexpress gridcontrol中使用buttonedit - how to use buttonedit in devexpress gridcontrol 如何在 devexpress 中向 GridControl 添加控件? - How to add controls to a GridControl in devexpress? 如何选择性地显示和不显示绑定到devexpress winform的gridcontrol的BindingList中的对象的列? - How to selectively display and not display column of object in BindingList which is bond to gridcontrol of devexpress winform? 如何在DevExpress GridControl中填充最后一列的宽度? - How to fill width of last column at DevExpress GridControl? 如何在未绑定的devexpress GridControl中添加新行? - How to add new row to unbound devexpress GridControl? 如何在MFC中使用的WPF控件中更改DevExpress GridControl默认主题 - How to change DevExpress GridControl default theme in WPF control which is used in MFC 如何用动态对象填充DevExpress GridControl - How to populate DevExpress GridControl with Dynamic Objects
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM