public void Dispose() { if (_PopupForm != null) { _PopupForm.Dispose(); _PopupForm = null; } }
/// <summary> /// 弹出下拉列表 /// </summary> /// <param name="control">要显示的数据内容控件</param> /// <returns>用户是否确认数据编辑操作</returns> public void DropDownControl(Control control) { _UserAccept = false; if (control == null) { throw new ArgumentNullException("control"); } if (_PopupForm == null) { _PopupForm = new XPopupForm(); _PopupForm.OwnerControl = this._EditControl; //_PopupForm.ControlBox = true; } Size size = control.GetPreferredSize(new Size(0, 300)); // .Size; _PopupForm.ClientSize = new Size( size.Width + 5 + PopupFormSizeFix.Width, size.Height + 5 + PopupFormSizeFix.Height); WindowInformation info = new WindowInformation(_PopupForm.Handle); Rectangle rect2 = info.Bounds; Rectangle crect2 = info.ClientBounds; _PopupForm.Controls.Clear(); _PopupForm.Controls.Add(control); control.Dock = DockStyle.Fill; if (_PopupForm.ClientSize.Width < control.Width) { } _PopupForm.AutoClose = true; //_PopupForm.CanGetFocus = true; //_PopupForm.Visible = true; //_PopupForm.Show(); ImeMode back = ImeMode.NoControl; if (this._EditControl != null && _EditControl.IsHandleCreated && _EditControl.IsDisposed == false && _ElementInstance != null) { _PopupForm.Owner = this._EditControl.FindForm(); _PopupForm.TopMost = (_PopupForm.Owner != null); if (this._ElementInstance is DomElement) { DomElement element = (DomElement)this._ElementInstance; if (!(element is DomParagraphFlagElement)) { element = element.FirstContentElement; } if (element == null) { goto EndFunction; } Rectangle rect = this._EditControl.GetCompositionRect( element.AbsLeft, element.AbsTop, element.Height); _PopupForm.CompositionRect = rect; _PopupForm.UpdateComposition(); } _PopupForm.Show(); if (control is MonthCalendar) { MonthCalendar mc = (MonthCalendar)control; size = mc.Size; _PopupForm.ClientSize = new Size( size.Width + PopupFormSizeFix.Width, size.Height + PopupFormSizeFix.Height); } else if (control is DateTimeSelectControl) { DateTimeSelectControl dtc = (DateTimeSelectControl)control; size = dtc.GetPreferredSize(Size.Empty); _PopupForm.ClientSize = new Size( size.Width + PopupFormSizeFix.Width, size.Height + PopupFormSizeFix.Height); } if (_PopupForm.CanGetFocus == false) { if (ForceFousePopupControl) { this._EditControl.Focus(); } } back = _EditControl.ImeMode; _EditControl.ImeMode = ImeMode.Disable; }//if _PopupForm.WaitUserSelected(); EndFunction: _PopupForm.CloseList(); if (_PopupForm != null) { _PopupForm.Controls.Clear(); } if (control != null) { control.Dispose(); } if (_EditControl != null) { _EditControl.ImeMode = back; _EditControl.Focus(); } //_UserAccept = ( _PopupForm.UserProcessState == UserProcessState.Accept ); }