【发布时间】:2018-01-04 21:16:30
【问题描述】:
我有一个为波斯日历准备的自定义 DateTimePicker 控件。有没有办法将它添加到 DevExpress GridControl 列? 请帮帮我。
【问题讨论】:
我有一个为波斯日历准备的自定义 DateTimePicker 控件。有没有办法将它添加到 DevExpress GridControl 列? 请帮帮我。
【问题讨论】:
发件人:Creating a custom (RepositoryItem) ImageComboBox
如果您希望在 GridControl 中使用您的自定义控件,则必须 创建编辑器及其 RepositoryItem 后代。
完整信息请参阅Custom Editors 和How to register a custom editor for use in the XtraGrid 文章 关于如何创建自定义控件。你可以找到一些自定义编辑器 我们示例中的后代:editor descendants。
RepositoryItem 类包含编辑器设置并用作 网格中单元格的模板。在显示模式下,GridControl 仅通过 RepositoryItem 的方法绘制单元格内容。在编辑 模式下,GridControl 通过 RepositoryItem.CreateEditor 方法。因此,如果您希望将项目添加到 网格初始化时使用的编辑器,在 RepositoryItem 级别。
如果您使用以下代码处理GridView.CustomRowCellEdit 事件,您可以为自动过滤行设置编辑器
RepositoryItemDateEdit rd = new RepositoryItemDateEdit();
void gridView1_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e) {
GridView view = sender as GridView;
if(e.Column.FieldName == "DOB" && view.IsFilterRow(e.RowHandle)) {
e.RepositoryItem = rd;
}
}
查看Assigning Editors to Columns and Card Fields 帮助文章,了解如何将特定编辑器分配给特定 GridView 的列。
我希望这些信息对您有用。
【讨论】: