コード例 #1
0
ファイル: CtlChooser.cs プロジェクト: lmedvedev/PioFramework
        private void btnDropDown_Click(object sender, EventArgs e)
        {
            if (_Service == null)
            {
                _Service = new DropDownService(this);
            }
            buildColumns();
            ChooserDropDown ctl = NewChooserDropDown();

            ctl.CloseByDoubleClick = CloseDropDownByDoubleClick;

            ctl.DataSource = SetClass;

            if (SetClass != null)
            {
                if (SetClass.Count == 0)
                {
                    SetClass.Load();
                }

                SetClass.FilterApply(((Value == null) ? txtMain.Text : ""), ctl.GetColumnDescriptors());
            }
            ctl.Value = Value;
            _Service.DropDownControl(ctl);
        }
コード例 #2
0
        public void DropDownControl(Control ctl)
        {
            DropDownCtl = (ChooserDropDown)ctl;
            if (editor.CanCall)
            {
                DropDownCtl.ValueOpenForm += new ValueEventHandler(DropDownService_ValueOpenForm);
            }
            if (dropDownForm == null)
            {
                dropDownForm = new DropDownForm(this);
            }
            dropDownForm.TopMost   = true;
            dropDownForm.Visible   = false;
            dropDownForm.Component = DropDownCtl;

            Size size = new Size(editor.DropDownWidth, editor.DropDownHeight);

            Point location = new Point(editor.Left, editor.Bottom);

            if (editor.DropDownAlign == CtlChooser.DropDownAlignment.Right)
            {
                location.X = editor.Right - size.Width - 1;
            }

            // location in screen coordinate
            location = editor.Parent.PointToScreen(location);

            // check the form is in the screen working area
            Rectangle screenWorkingArea = Screen.FromControl(editor).WorkingArea;

            location.X = Math.Min(screenWorkingArea.Right - size.Width,
                                  Math.Max(screenWorkingArea.X, location.X));

            if (size.Height + location.Y + editor.Height > screenWorkingArea.Bottom)
            {
                location.Y = location.Y - size.Height - editor.Height - 1;
            }

            dropDownForm.FormBorderStyle = FormBorderStyle.FixedSingle;
            dropDownForm.SetBounds(location.X, location.Y, size.Width, size.Height);
            dropDownForm.MinimumSize = size;
            dropDownForm.Size        = size;
            dropDownForm.Visible     = true;
            DropDownCtl.Focus();
            DropDownCtl.ValueSelected -= new ValueEventHandler(ctl_ValueSelected);
            DropDownCtl.ValueSelected += new ValueEventHandler(ctl_ValueSelected);
            DropDownCtl.ValueEscaped  -= new EventHandler(DropDownService_ValueEscaped);
            DropDownCtl.ValueEscaped  += new EventHandler(DropDownService_ValueEscaped);

            //editor.SelectTextBox();
            // wait for the end of the editing

            //while (dropDownForm.Visible)
            //{
            //    Application.DoEvents();
            //    MsgWaitForMultipleObjects(0, 0, true, 250, 255);
            //}

            // editing is done or aborted
        }