简体   繁体   English

C#Devexpress:GridControl添加组合框

[英]C# Devexpress : GridControl Add Combobox

I need to change the cell editor to ComboBox. 我需要将单元格编辑器更改为ComboBox。 I want a specific cell to change ComboBox in the gridControl1? 我想要特定的单元格来更改gridControl1中的ComboBox吗?

Check the desired functionality - Image 检查所需的功能-图片

I suggest you go through the documentation - Assigning Editors to Individual Cells 我建议您仔细阅读文档- 将编辑器分配给各个单元

At runtime, you can assign editors to individual cells by handling the GridView.CustomRowCellEdit (or LayoutView.CustomRowCellEdit ) event. 在运行时,可以通过处理GridView.CustomRowCellEdit (或LayoutView.CustomRowCellEdit )事件将编辑器分配给各个单元。 The event occurs dynamically for each visible cell and allows you to supply an editor to individual cells, based on the position of the cell (its column and row). 该事件在每个可见单元格中动态发生,并允许您根据单元格的位置(其列和行)为单个单元格提供编辑器。

example: 例:

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