码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2019-05-21 12:37:58      阅读:536      评论:0      收藏:0      [点我收藏+]

标签:text   layout   isp   end   pup   rgs   pop   void   事件   

基本设置,绑定数据

                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使用回车选择首行数据

标签:text   layout   isp   end   pup   rgs   pop   void   事件   

原文地址:https://www.cnblogs.com/xyz0835/p/10899091.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!