DevExpress的GridView中指定不同的编辑器

主要通过CustomRowCellEdit事件里指定。需要注意一点,如果不是通过Run Designer里添加的repositoryItem项目,则需要RepositoryItems中手动添加下编辑器,如示例里添加的是颜色编辑器:

RepositoryItemColorPickEdit edit = new RepositoryItemColorPickEdit();
gdcProperties.RepositoryItems.Add(edit);

 然后添加GridView中CustomRowCellEdit事件: 

//初始化或load方法中加入事件
gdvProperties.CustomRowCellEdit += GdvProperties_CustomRowCellEdit;

private void GdvProperties_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e)
{
     if (e.Column.FieldName == "Value" && e.RowHandle == 8)
     {
          e.RepositoryItem = edit;
     }
}

 

 

posted @ 2022-08-07 17:26  东经115  阅读(274)  评论(0编辑  收藏  举报