繁体   English   中英

C#Devexpress:GridControl添加组合框

[英]C# Devexpress : GridControl Add Combobox

我需要将单元格编辑器更改为ComboBox。 我想要特定的单元格来更改gridControl1中的ComboBox吗?

检查所需的功能-图片

我建议您仔细阅读文档- 将编辑器分配给各个单元

在运行时,可以通过处理GridView.CustomRowCellEdit (或LayoutView.CustomRowCellEdit )事件将编辑器分配给各个单元。 该事件在每个可见单元格中动态发生,并允许您根据单元格的位置(其列和行)为单个单元格提供编辑器。

例:

using DevExpress.XtraGrid.Views.Grid;

private void gridView1_CustomRowCellEdit(object sender, CustomRowCellEditEventArgs e) {
   if (e.Column.FieldName != "ShipCity") return;
   GridView gv = sender as GridView;
   string fieldValue = gv.GetRowCellValue(e.RowHandle,gv.Columns["ShipCountry"]).ToString();
   switch (fieldValue) {
      case "France":
         e.RepositoryItem = repositoryItemComboBox1;
         break;
      case "USA":
         e.RepositoryItem = repositoryItemComboBox2;
         break;
   }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM