views:

170

answers:

2

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

+1  A: 

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.

Andrea Parodi
i have given what you specified above but its not clearing the values and items showing 2 times . I given code above
Vyas
In the code above, you are re-bindng the list of the editor to _lab.selectChemicals (), so you get values from selectChemicals () in the list. This is not what you expect to happens?
Andrea Parodi
am calling above method when insert new value.So it bind the new value to LookupEdit.But it show same item as 2 section
Vyas
I'm not sure if I've understood: user types "Reference1" in the edit portion, then click on "+" to add "Reference1" to hte linked table?
Andrea Parodi
A: 

Got items correctly.

problem is that am creating `LookUpColumnInfo whenever am calling same method. 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;

create LookUpColumnInfo only first time then call method without LookUpColumnInfo

Vyas