【问题标题】:RipositoryItemCombobox value not set in devexpress gridview未在 devexpress gridview 中设置 RipositoryItemCombobox 值
【发布时间】:2015-09-22 11:48:01
【问题描述】:

我在 C# 中创建了 windows 应用程序,在该应用程序中我在第一列中使用了 devexpress 的 gridview 控件,我使用了 repositoryitemcombobox 并在 repositorycombobox 中绑定数据。组合框有数据,当从下拉列表中选择任何数据时,它会从下拉列表中显示选定的值,但是当移动到下一列时,上一列的值显示 null

例子:

private void gridView1_InitNewRow(object sender, InitNewRowEventArgs e) {
      FoundryBusinessAccess bal = new FoundryBusinessAccess();
      RepositoryItemComboBox comproduct = new RepositoryItemComboBox();
      DataTable dtpro = new DataTable();
      dtpro = bal.SelectProductName();
      List<string> listdata = dtpro.AsEnumerable().Select(r => r.Field<string>("prod_name")).ToList();
      foreach (object list in listdata) {
          comproduct.Items.Add(list.ToString());
      }
      gridControl1.RepositoryItems.Add(comproduct);
      prod_name.ColumnEdit = comproduct;
}

【问题讨论】:

    标签: c# gridview devexpress


    【解决方案1】:

    您使用了错误的事件 - 您应该改用 CustomRowCellEdit 和/或 CustomRowCellEditForEditing 事件。从他们的文档Assigning Editors to Individual Cells 中阅读以下主题。

    【讨论】:

    • 我正在从数据库绑定 repositoryitemcombobox,在这种情况下,CustomRowCellEdit 事件不起作用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-19
    • 1970-01-01
    • 1970-01-01
    • 2013-11-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多