网上有大量的给Devexpress的Grid某列指定编辑器的文章,但很少给行指定编辑控件的,使用本文的方法不仅可以给数据行指定编辑器,甚至可以为每个单元格指定一个编辑器
先看一下效果图:
1. 定义两个ComboBox:
public DevExpress.XtraEditors.Repository.RepositoryItemComboBox ricbAlign = new DevExpress.XtraEditors.Repository.RepositoryItemComboBox();
public DevExpress.XtraEditors.Repository.RepositoryItemComboBox ricbShow = new DevExpress.XtraEditors.Repository.RepositoryItemComboBox();
2. 在窗口的Load事件中,给ComboBox增加Items, 并添加到到 gridControl2.RepositoryItems
ricbAlign.Items.AddRange(new object[] { "居左", "居中", "居右", "默认" });
ricbShow.Items.AddRange(new object[] { "显示", "隐藏" });
gridControl2.RepositoryItems.AddRange(new DevExpress.XtraEditors.Repository.Reposi