【问题标题】:How to clear items in DevExpress LookupEdit如何在 DevExpress LookupEdit 中清除项目
【发布时间】:2011-04-06 17:48:43
【问题描述】:

嘿, 我在 C#.NET 应用程序中使用 DevExpress LookupEdit。我想清除 LookupEdit 中的所有项目。请帮助

代码:

lkpLabItem.Properties.DataSource = null; 
         lkpLabItem .Properties.DataSource = _lab.selectChemicals ();
         lkpLabItem.Properties.DisplayMember = "labitem_Name";
         lkpLabItem.Properties.ValueMember = "labItem_ID";
         lkpLabItem.Properties.BestFitMode = BestFitMode.BestFit;
         lkpLabItem.Properties.SearchMode = SearchMode.AutoComplete;

         lkpLabItem.Properties.Columns.Add(new LookUpColumnInfo("labitem_Name", 100, "Lab Items"));
         lkpLabItem.Properties.AutoSearchColumnIndex = 1;

谢谢。

【问题讨论】:

    标签: c# winforms devexpress repositorylookupedit


    【解决方案1】:

    LookupEdit 是指提供来自链接数据源的数据列表,因此,要清除项目,您可以将其 DataSource 属性设置为 null:

    lookUpEdit1.Properties.DataSource = null;
    

    或者,如果您使用 BindingSource 作为 LookupEdit 数据源,您可以将其 DataSource 属性设置为 null。

    【讨论】:

    • 我已经给出了您上面指定的内容,但它没有清除显示 2 次的值和项目。我在上面给出了代码
    • 在上面的代码中,你将编辑器的列表重新绑定到_lab.selectChemicals(),所以你从列表中的selectChemicals()中获取值。这不是您期望发生的事情?
    • 在插入新值时调用上述方法。因此它将新值绑定到 LookupEdit。但它显示与 2 部分相同的项目
    • 我不确定我是否理解:用户在编辑部分输入“Reference1”,然后点击“+”将“Reference1”添加到链接表?
    【解决方案2】:

    正确获取物品。

    问题是每当调用相同的方法时都会创建 `LookUpColumnInfo。 代码:

    lkpLabItem.Properties.DataSource = null; 
             lkpLabItem .Properties.DataSource = _lab.selectChemicals ();
             lkpLabItem.Properties.DisplayMember = "labitem_Name";
             lkpLabItem.Properties.ValueMember = "labItem_ID";
             lkpLabItem.Properties.BestFitMode = BestFitMode.BestFit;
             lkpLabItem.Properties.SearchMode = SearchMode.AutoComplete;
    

    只在第一次创建LookUpColumnInfo然后调用没有LookUpColumnInfo的方法

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-06
      • 1970-01-01
      • 2019-08-06
      • 2014-10-07
      • 2011-01-13
      • 1970-01-01
      相关资源
      最近更新 更多