本示例主要展示如何在XtraGrid网格控件(包含在DevExpress WinForms套包中)的主视图中指定HyperLinkEdit控件作为列编辑器。
首先,我们需要创建一个相应的repository item,并将其添加到EditorContainer.RepositoryItems属性所指定的repository items的内部集合中。然后,利用GridColumn.ColumnEdit属性,将repository item分配到列。
C#
RepositoryItemHyperLinkEdit repHyperLink = new RepositoryItemHyperLinkEdit();
gridControl1.RepositoryItems.Add(repHyperLink);
(gridControl1.MainView as GridView).Columns["EMAIL"].ColumnEdit = repHyperLink;
//customize the editor
repHyperLink.LinkColor = Color.Maroon
repHyperLink.Caption = "Click to e-mail"
VB
Dim repHyperLink As RepositoryItemHyperLinkEdit = New RepositoryItemHyperLinkEdit
GridControl1.RepositoryItems.Add(repHyperLink)
CType(GridControl1.MainView, GridView).Columns(0).ColumnEdit = repHyperLink
'customize the editor
repHyperLink.LinkColor = Color.Maroon
repHyperLink.Caption = "Click to e-mail"
运行代码,结果如下:
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [https://www.devexpresscn.com/]
本文地址:https://www.devexpresscn.com/post/381.html