Current filter:
                                You should refresh the page.
                                Support Center

                                How to create a data source wrapper that adds an empty item to the lookup list

                                0

                                This example demonstrates how to display an empty (blank) item in the dropdown list of the LookUpEdt control. This approach is also applicable to GridLookUpEdit / RepositoryItemGridLookUpEdit.

                                See Also:
                                How to clear the currently selected value in the LookUp editor

                                You must  log in  or  register  to leave comments
                                Select file
                                • Form1.cs
                                • Program.cs
                                • DataSourceWithEmptyItem.cs
                                Select language
                                • C#
                                • VB.NET
                                Select version
                                • v2008 vol 2.7 - v2012 vol 2.7
                                using System;
                                using System.Collections.Generic;
                                using System.ComponentModel;
                                using System.Data;
                                using System.Drawing;
                                using System.Text;
                                using System.Windows.Forms;
                                using DevExpress.Xpo;
                                using DevExpress.XtraEditors;
                                
                                namespace LookUpListWithNullEntry {
                                    public partial class Form1 : Form {
                                        public Form1() {
                                            InitializeComponent();
                                
                                            FillData();
                                
                                            this.repositoryItemLookUpEdit1.DataSource = new DataSourceWithEmptyItem(this.xpc2);
                                        }
                                
                                        private void FillData() {
                                            if(xpc2.Count == 0) {
                                                Lookup lookup = new Lookup();
                                                lookup.Description = "Description 1";
                                                lookup.Save();
                                                xpc2.Add(lookup);
                                            }
                                        }
                                
                                        private void repositoryItemLookUpEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) {
                                            if(e.Button.Kind == DevExpress.XtraEditors.Controls.ButtonPredefines.Delete) {
                                                LookUpEdit editor = (LookUpEdit)sender;
                                                editor.CancelPopup();
                                                editor.EditValue = null;
                                            }
                                        }
                                    }
                                
                                    public class Main : XPObject {
                                        public string Name;
                                        public Lookup Description;
                                    }
                                
                                    public class Lookup : XPObject {
                                        public string Description;
                                    }
                                }

                                To start a chat you should create a support ticket


                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Your Privacy - Legal Statements

                                Copyright © 1998-2013 Developer Express Inc.
                                ALL RIGHTS RESERVED
                                All trademarks or registered trademarks
                                are property of their respective owners