コード例 #1
0
        void PopupForm_KeyUp(object sender, KeyEventArgs e)
        {
            bool gotMatch = false;
            PopupSearchLookUpEditForm popupForm = sender as PopupSearchLookUpEditForm;

            if (e.KeyData == Keys.Enter)
            {
                string searchText = popupForm.Properties.View.FindFilterText;
                if (!string.IsNullOrEmpty(searchText))
                {
                    GridView view = popupForm.OwnerEdit.Properties.View;
                    //If there is a match is on the ValueMember (Code) column, that should take precedence
                    //This needs to be case insensitive, but there is no case insensitive lookup, so we have to iterate the rows
                    //int row = view.LocateByValue(popupForm.OwnerEdit.Properties.ValueMember, searchText);
                    for (int row = 0; row < view.DataRowCount; row++)
                    {
                        CodeName codeName = (CodeName)view.GetRow(row);
                        if (codeName.Code.Equals(searchText.Trim('"'), StringComparison.OrdinalIgnoreCase))
                        {
                            view.FocusedRowHandle = row;
                            gotMatch = true;
                            break;
                        }
                    }
                    if (!gotMatch)
                    {
                        view.FocusedRowHandle = 0;
                    }
                    popupForm.OwnerEdit.ClosePopup();
                }
            }
        }
コード例 #2
0
        private void repLineEntity_Popup(object sender, EventArgs e)
        {
            IPopupControlEx           popupControl = sender as IPopupControlEx;
            PopupSearchLookUpEditForm popupWindow  = (PopupSearchLookUpEditForm)popupControl.PopupWindow;

            DevExpress.XtraGrid.Editors.SearchEditLookUpPopup control = (DevExpress.XtraGrid.Editors.SearchEditLookUpPopup)popupWindow.Controls[2];

            control.FindTextBox.KeyDown += (insender, ine) =>
            {
                if (ine.KeyCode == Keys.Enter)
                {
                    if (grvItems.ActiveEditor == null || (grvItems.ActiveEditor as DevExpress.XtraEditors.SearchLookUpEdit) == null)
                    {
                        return;
                    }

                    var searchValue = (insender as DevExpress.XtraEditors.TextEdit).Text;

                    if (DataContext.ReadonlyContext.VW_LineItem.Where(n => n.Name == searchValue).Count() == 1)
                    {
                        (grvItems.ActiveEditor as DevExpress.XtraEditors.SearchLookUpEdit).EditValue =
                            DataContext.ReadonlyContext.VW_LineItem.Where(n => n.Name == searchValue).Select(l => l.Id).FirstOrDefault();
                        grvItems.SetFocusedRowCellValue(colItemId, (grvItems.ActiveEditor as DevExpress.XtraEditors.SearchLookUpEdit).EditValue);
                        SendKeys.SendWait("{ENTER}");
                        SendKeys.SendWait("{ENTER}");
                    }
                }
            };
        }
コード例 #3
0
ファイル: DocumentAlert.cs プロジェクト: tslekwadi/CDS
        /// <summary>
        /// KeyDown Event for the SearchLookUpEdit's TextEdit
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void searchTextEdit_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Return)
            {
                PopupSearchLookUpEditForm parentForm = ((TextEdit)sender).FindForm() as PopupSearchLookUpEditForm;
                GridControl grid = FindGridControl(parentForm);
                if (grid == null)
                {
                    return;
                }

                GridView view = grid.MainView as GridView;
                if (view.DataRowCount == 1)
                {
                    view.FocusedRowHandle = 0;
                    view.Focus();
                    SendKeys.SendWait("{Enter}");
                    //parentForm.OwnerEdit.ClosePopup();
                }
                else if (view.DataRowCount > 1)
                {
                    view.FocusedRowHandle = 0;
                    view.Focus();
                }
            }
        }
コード例 #4
0
        private void searchLookUpEdit1_Popup(object sender, EventArgs e)
        {
            //得到当前SearchLookUpEdit弹出窗体
            PopupSearchLookUpEditForm form   = (sender as IPopupControl).PopupWindow as PopupSearchLookUpEditForm;
            SearchEditLookUpPopup     popup  = form.Controls.OfType <SearchEditLookUpPopup>().FirstOrDefault();
            LayoutControl             layout = popup.Controls.OfType <LayoutControl>().FirstOrDefault();

            //如果窗体内空间没有确认按钮,则自定义确认simplebutton,取消simplebutton,选中结果label
            if (layout.Controls.OfType <Control>().Where(ct => ct.Name == "btOK").FirstOrDefault() == null)
            {
                //得到空的空间
                EmptySpaceItem a = layout.Items.Where(it => it.TypeName == "EmptySpaceItem").FirstOrDefault() as EmptySpaceItem;

                //得到取消按钮,重写点击事件
                Control           clearBtn = layout.Controls.OfType <Control>().Where(ct => ct.Name == "btClear").FirstOrDefault();
                LayoutControlItem clearLCI = (LayoutControlItem)layout.GetItemByControl(clearBtn);
                clearBtn.Click += clearBtn_Click;

                //添加一个simplebutton控件(确认按钮)
                LayoutControlItem myLCI = (LayoutControlItem)clearLCI.Owner.CreateLayoutItem(clearLCI.Parent);
                myLCI.TextVisible = false;
                SimpleButton btOK = new SimpleButton()
                {
                    Name = "btOK", Text = "确定"
                };
                btOK.Click               += btOK_Click;
                myLCI.Control             = btOK;
                myLCI.SizeConstraintsType = SizeConstraintsType.Custom;//控件的大小设置为自定义
                myLCI.MaxSize             = clearLCI.MaxSize;
                myLCI.MinSize             = clearLCI.MinSize;
                myLCI.Move(clearLCI, DevExpress.XtraLayout.Utils.InsertType.Left);
            }
        }
コード例 #5
0
        private static void ItemCtrl_SearchLookUpEdit_Popup(object sender, EventArgs e)
        {
            SearchLookUpEdit          edit      = sender.CastTo <SearchLookUpEdit>();
            PopupSearchLookUpEditForm popupForm = edit.GetPopupEditForm();

            popupForm.KeyPreview = true;
            popupForm.KeyPress  += PopupForm_KeyPress;
        }
コード例 #6
0
        private void clkOuterItem_Popup(object sender, EventArgs e)
        {
            PopupSearchLookUpEditForm popupForm = (sender as IPopupControl).PopupWindow as PopupSearchLookUpEditForm;

            popupForm.KeyPreview = true;
            popupForm.KeyUp     -= popupForm_KeyUp;
            popupForm.KeyUp     += popupForm_KeyUp;
        }
コード例 #7
0
 public static void EnterToSelectFirstRow(RepositoryItemSearchLookUpEdit slu)
 {
     slu.Popup += (s1, e1) =>
     {
         PopupSearchLookUpEditForm popupForm = (s1 as IPopupControl).PopupWindow as PopupSearchLookUpEditForm;
         popupForm.KeyPreview = true;
         popupForm.KeyUp     -= popupForm_KeyUp;
         popupForm.KeyUp     += popupForm_KeyUp;
     };
 }
コード例 #8
0
 private static void PopupForm_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == (char)Keys.Enter)
     {
         PopupSearchLookUpEditForm popupForm = sender as PopupSearchLookUpEditForm;
         var view = popupForm.OwnerEdit.Properties.View;
         view.FocusedRowHandle = 0;
         popupForm.OwnerEdit.ClosePopup();
     }
 }
コード例 #9
0
        private static void txt_KeyUp(object sender, KeyEventArgs e)
        {
            PopupSearchLookUpEditForm popupForm = sender as PopupSearchLookUpEditForm;

            if (e.KeyData == System.Windows.Forms.Keys.Enter)
            {
                GridView view = popupForm.OwnerEdit.Properties.View;
                view.FocusedRowHandle = 0;
                popupForm.OwnerEdit.ClosePopup();
            }
        }
コード例 #10
0
        void popupForm_KeyUp(object sender, KeyEventArgs e)
        {
            PopupSearchLookUpEditForm popupForm = sender as PopupSearchLookUpEditForm;

            if (e.KeyData == Keys.Enter)
            {
                GridView view = popupForm.OwnerEdit.Properties.View;
                view.FocusedRowHandle = 0;
                popupForm.OwnerEdit.ClosePopup();
            }
        }
コード例 #11
0
ファイル: frmSearchLookupTest.cs プロジェクト: sohret/Maga
        private void grid_Popup(object sender, EventArgs e)
        {
            PopupSearchLookUpEditForm popupForm = (sender as IPopupControl).PopupWindow as PopupSearchLookUpEditForm;
            PropertyInfo pi = typeof(PopupSearchLookUpEditForm).GetProperty("FindEdit", BindingFlags.Instance | BindingFlags.NonPublic);

            findEdit              = pi.GetValue(popupForm, null) as TextEdit;
            findEdit.TextChanged += findEdit_TextChanged;
            findEdit              = (sender as IPopupControl).PopupWindow.Controls[2].Controls[0].Controls[7] as TextEdit;
            findEdit.Text         = searchText;


            popupForm.KeyDown += popupForm_KeyDown;
        }
コード例 #12
0
        /// <summary>
        ///     Получить доступ к TextEdit в всплывающем окне у SearchLookUp
        /// </summary>
        /// <param name="popupForm">SearchLookUp</param>
        public static TextEdit FindTextInputField(this PopupSearchLookUpEditForm popupForm)
        {
            if (popupForm == null)
            {
                return(null);
            }
            var foundControls = popupForm.Controls.Find("teFind", true);

            if (foundControls.Length == 0)
            {
                return(null);
            }
            return((TextEdit)foundControls[0]);
        }
コード例 #13
0
        private void SearchLookupEdit_Popup(object sender, EventArgs e)
        {
            //Hide the Find button because it doesn't do anything when auto - filtering, except it
            //is useful to let the user know the purpose of the filter field, because it has no label
            //LayoutControl lc = ((sender as IPopupControl).PopupWindow.Controls[2].Controls[0] as LayoutControl);
            //((lc.Items[0] as LayoutControlGroup).Items[1] as LayoutControlGroup).Items[1].Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;

            PopupSearchLookUpEditForm popupForm = (sender as IPopupControl).PopupWindow as PopupSearchLookUpEditForm;

            popupForm.KeyPreview = true;
            popupForm.KeyUp     -= PopupForm_KeyUp;
            popupForm.KeyUp     += PopupForm_KeyUp;

            //SearchLookUpEdit currentSearch = (SearchLookUpEdit)sender;
        }
コード例 #14
0
        private void searchLookUpEdit1_Popup(object sender, EventArgs e)
        {
            //得到当前SearchLookUpEdit弹出窗体
            PopupSearchLookUpEditForm form   = (sender as IPopupControl).PopupWindow as PopupSearchLookUpEditForm;
            SearchEditLookUpPopup     popup  = form.Controls.OfType <SearchEditLookUpPopup>().FirstOrDefault();
            LayoutControl             layout = popup.Controls.OfType <LayoutControl>().FirstOrDefault();

            //如果窗体内空间没有确认按钮,则自定义确认simplebutton,取消simplebutton,选中结果label
            if (layout.Controls.OfType <Control>().Where(ct => ct.Name == "btOK").FirstOrDefault() == null)
            {
                //得到空的空间
                EmptySpaceItem a = layout.Items.Where(it => it.TypeName == "EmptySpaceItem").FirstOrDefault() as EmptySpaceItem;

                //得到取消按钮,重写点击事件
                Control           clearBtn = layout.Controls.OfType <Control>().Where(ct => ct.Name == "btClear").FirstOrDefault();
                LayoutControlItem clearLCI = (LayoutControlItem)layout.GetItemByControl(clearBtn);
                clearBtn.Click += clearBtn_Click;

                //添加一个simplebutton控件(确认按钮)
                LayoutControlItem myLCI = (LayoutControlItem)clearLCI.Owner.CreateLayoutItem(clearLCI.Parent);
                myLCI.TextVisible = false;
            }
        }
コード例 #15
0
        public static void Bind(this SearchLookUpEdit searchLookUpEdit, Entity entity, CriteriaOperator filter)
        {
            if (entity == null)
            {
                return;
            }
            if (searchLookUpEdit.DataBindings.Count == 0)
            {
                return;
            }

            var binding = searchLookUpEdit.DataBindings[0];

            string attributeName = binding.BindingMemberInfo.BindingMember;

            var attribute = entity.Attributes.FirstOrDefault(a => a.PhysicalName.Equals(attributeName));

            if (attribute == null)
            {
                throw new Exception("Attribute Not found:entity =" + entity.Name + " attribute = " + attributeName);
            }
            var lookupValue       = attribute.AttributeLookupValues.First();
            var lookupValueEntity = lookupValue.Entity;

            searchLookUpEdit.Properties.BeginInit();

            var entityName       = lookupValueEntity.PhysicalName;
            var displayAttribute =
                lookupValueEntity.Attributes.First(a => a.AttributeId == lookupValue.DisplayEntityAttributeId);

            searchLookUpEdit.Properties.DisplayMember = displayAttribute.PhysicalName;

            var primaryKeyAttribute =
                lookupValueEntity.Attributes.Single(a => a.IsPKAttribute.HasValue && a.IsPKAttribute.Value);

            searchLookUpEdit.Properties.ValueMember    = primaryKeyAttribute.PhysicalName;
            searchLookUpEdit.Properties.NullText       = string.Empty;
            searchLookUpEdit.Properties.AllowNullInput = DefaultBoolean.True;
            searchLookUpEdit.Properties.TextEditStyle  = TextEditStyles.DisableTextEditor;
            searchLookUpEdit.Properties.ShowFooter     = true;

            searchLookUpEdit.Popup += (sender, e) =>
            {
                PopupSearchLookUpEditForm popup = (PopupSearchLookUpEditForm)(searchLookUpEdit as DevExpress.Utils.Win.IPopupControl).PopupWindow;
                popup.CloseButton.Width           = 0;
                popup.CloseButton.Height          = 0;
                popup.CloseButton.Visible         = false;
                popup.CloseButton.VisibleChanged += (o, ex) =>
                {
                    popup.CloseButton.Visible = false;
                };
            };

            searchLookUpEdit.Properties.View.InitWithDefaultLayout(entityName);

            ODataListSource source = new ODataListSource(entityName, filter, null);

            source.AsyncRefreshDataSource();
            searchLookUpEdit.Properties.DataSource = source;
            searchLookUpEdit.Properties.EndInit();
        }