DevExpress SearchLookUpEdit使用回车选择首行数据

Posted xyz0835

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了DevExpress SearchLookUpEdit使用回车选择首行数据相关的知识,希望对你有一定的参考价值。

基本设置,绑定数据

                searchEdit.Properties.ValueMember = "ID";
                searchEdit.Properties.DisplayMember = "Name";
                searchEdit.Properties.DataSource = dt;
                searchEdit.Properties.Popup += Properties_Popup;

  

在popup事件中添加

 

        private void Properties_Popup(object sender, EventArgs e)
        {
            TextEdit txt = (sender as IPopupControl).PopupWindow.Controls.Cast<Control>().FirstOrDefault(item => item is SearchEditLookUpPopup).Controls.Cast<Control>().FirstOrDefault(item => item is LayoutControl).Controls.Cast<Control>().FirstOrDefault(item => item is TextEdit) as TextEdit;

            if (txt.Tag != null)
                return;

            txt.Tag = "KeyDown";
            txt.KeyDown += txt_KeyDown;
        }

        void txt_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                TextEdit txt = sender as TextEdit;
                SearchLookUpEdit lookUpEdit = (txt.TopLevelControl as PopupSearchLookUpEditForm).OwnerEdit as SearchLookUpEdit;
                GridView gv = lookUpEdit.Properties.View as GridView;
                gv.FocusedRowHandle = 0;
                lookUpEdit.ClosePopup();
            }
        }

  

以上是关于DevExpress SearchLookUpEdit使用回车选择首行数据的主要内容,如果未能解决你的问题,请参考以下文章

devexpress demo 的源码 在哪儿

devexpress vcl 哪个版本支持d7

转DevExpress控件安装

devexpress 15.2怎么破解

[DevExpress]DevExpress的安装与使用

C#开发中控件devexpress