How to clear items in DevExpress LookupEdit

Vyasdev Meledath picture Vyasdev Meledath · Sep 1, 2010 · Viewed 14.6k times · Source

Hai, Am using DevExpress LookupEdit in C#.NET application.I want to clear all items in the LookupEdit.Please help

code:

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;

Thank you.alt text

Answer

Andrea Parodi picture Andrea Parodi · Sep 1, 2010

LookupEdit is mean to provide list of data from the linked datasource, so, to clear the items you can set its DataSource property to null:

lookUpEdit1.Properties.DataSource = null;

or, if you are using a BindingSource as the LookupEdit data source, you can set its DataSource property to null.