/// <summary> /// 遍历得到SearchLookUpEdit自带GridView中的按钮 /// </summary> /// <param name="Form"></param> /// <param name="strName"></param> /// <returns></returns> public static LayoutControlItem GetFindControlLayoutItem(PopupBaseForm Form, string strName) { if (Form != null) { foreach (Control FormC in Form.Controls) { if (FormC is SearchEditLookUpPopup) { SearchEditLookUpPopup SearchPopup = FormC as SearchEditLookUpPopup; foreach (Control SearchPopupC in SearchPopup.Controls) { if (SearchPopupC is LayoutControl) { LayoutControl FormLayout = SearchPopupC as LayoutControl; Control Button = FormLayout.GetControlByName(strName); if (Button != null) { return(FormLayout.GetItemByControl(Button)); } } } } } } return(null); }
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); } }
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; } }