Byte Commander
Byte Commander

Reputation: 6776

Allow empty/no selection in DevExpress' LookUpEdit

I have a form containing a DevExpress LookUpEdit (Windows Forms) which is bound to a list of objects with several displayed properties. The EditValue property is set to another object's property which will receive the selected value.

The user may select any item from the list of objects, but I also want to allow empty selections i.e. the EditValue would become null and the displayed text should be the default [No entry] then.

How could this be accomplished the easiest way?

Currently there's no way to clear the value after it has been set once.

Upvotes: 1

Views: 3939

Answers (3)

sandeep b j
sandeep b j

Reputation: 1

Add Cancel Button to your Lookup Edit and add reset code in Button Click event

Dim editor As LookUpEdit = CType(sender, LookUpEdit)

    If editor.Properties.Buttons.IndexOf(e.Button) = 0 Then
        YourLookUpEdit.EditValue = DBNull.Value
    End If

Upvotes: 0

Beldi Anouar
Beldi Anouar

Reputation: 2180

Try this one :

In form load :

 LookUpEditName.Properties.AllowNullInput = true ;
 LookUpEditName.Properties.NullText = "No entry";

and use LookUpEditName.EditValue = null; to clear the value

Upvotes: 0

Marko Juvančič
Marko Juvančič

Reputation: 5890

There are two options: 1. User can press Ctrl+Del to clear the value 2. However, this is not intuitive. What I do is add another value to the bound list.

var list = GetOriginalList(); // <- get all possible values
list.Add(new MyItem("[empty]", null)); // <- display name and ID

Upvotes: 1

Related Questions