1. 自定义合并单元格 假设 "Order Date" 列中包含日期/时间值。 如果视图的GridOptionsView.AllowCellMerge选项设置为true,若相邻两个单元格值是日期/时间值的话,这两个相邻单元格便会合并。下面的代码介绍了如何合并例单元格的日期部分,要覆盖默认的单元格合并机制,需要处理一下GridView.CellMerge事件。
C#
using DevExpress.XtraGrid.Views.Grid; // ... private void gridView1_CellMerge(object sender, CellMergeEventArgs e) { if(e.Column.FieldName == "Order Date") { GridView view = sender as GridView; DateTime val1 = (DateTime)view.GetRowCellValue(e.RowHandle1, e.Column);
VB
Imports DevExpress.XtraGrid.Views.Grid ' ... Private Sub GridView1_CellMerge(ByVal sender As Object, _ ByVal e As CellMergeEventArgs) Handles GridView1.CellMerge If (e.Column.FieldName = "Order Date") Then Dim view As GridView = CType(sender, GridView)
2. 指定HyperLinkEdit控件作为列编辑器 创建一个相应的repository item,并将其添加到EditorContainer.RepositoryItems属性所指定的repository items的内部集合中。 利用GridColumn.ColumnEdit属性,将repository item分配到列。
C#
RepositoryItemHyperLinkEdit repHyperLink = new RepositoryItemHyperLinkEdit(); gridControl1.RepositoryItems.Add(repHyperLink);
VB
Dim repHyperLink As RepositoryItemHyperLinkEdit = New RepositoryItemHyperLinkEdit GridControl1.RepositoryItems.Add(repHyperLink) CType(GridControl1.MainView, GridView).Columns(0).ColumnEdit =
3. 获取当前处于编辑状态的值
C#
string editingValue; if(gridControl1.KeyboardFocusView.IsEditing)
VB
Dim EditingValue As String If gridControl1.KeyboardFocusView.IsEditing Then
本站文章除注明转载外,均为本站原创或翻译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [https://www.devexpresscn.com/]
本文地址:https://www.devexpresscn.com/post/924.html
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [https://www.devexpresscn.com/]
本文地址:https://www.devexpresscn.com/post/924.html