Ejemplo n.º 1
0
        private void button_dropDownList_MouseDown(object sender, MouseEventArgs e)
        {
            Debug.WriteLine("MouseDown");

            /*
             * // TODO: MouseDown消息在下拉的LostFocus以后才得到,暂时无法解决识别问题
             * // 下拉已经显示的情况下,点本按钮
             * if (dlg != null && dlg.IsDisposed == false)
             * {
             *  // 不再重复打开
             *  return;
             * }
             * */

            if (this.DropDown != null)
            {
                this.DropDown(this, e);
            }

            PropertyStringDialog dlg = null;

            dlg                 = new PropertyStringDialog();
            dlg.Font            = this.Font;
            dlg.CheckedComboBox = this;
            dlg.Text            = this.Caption;
            dlg.PropertyString  = this.textBox_text.Text;
            dlg.Items           = this.Items;
            dlg.ReturnFirstPart = this.ReturnFirstPart;

            dlg.HideCloseButton = this.HideCloseButton;
            dlg.StartPosition   = FormStartPosition.Manual;
            dlg.Location        = this.PointToScreen(
                new Point(0,
                          0 + this.Size.Height)
                );
            if (this.DropDownWidth == -1)
            {
                int nWidth = this.Width;
                if (dlg.Width < nWidth)
                {
                    dlg.Width = nWidth;
                }
            }
            else
            {
                dlg.Width = this.DropDownWidth;
            }

            if (this.DropDownHeight != -1)
            {
                dlg.Height = this.DropDownHeight;
            }

            dlg.Show(); // 无模式对话框
            // dlg.ShowDialog(this);

            /*
             * if (dlg.DialogResult != DialogResult.OK)
             *  return;
             * */
            try
            {
                while (dlg.IsDisposed == false)
                {
                    Application.DoEvents();
                }
                Thread.Sleep(1);
            }
            catch
            {
            }

            this.textBox_text.Text = dlg.PropertyString;
        }
Ejemplo n.º 2
0
        private void button_dropDownList_MouseDown(object sender, MouseEventArgs e)
        {
            Debug.WriteLine("MouseDown");

            /*
             * // TODO: MouseDown消息在下拉的LostFocus以后才得到,暂时无法解决识别问题
            // 下拉已经显示的情况下,点本按钮
            if (dlg != null && dlg.IsDisposed == false)
            {
                // 不再重复打开
                return;
            }
             * */

            if (this.DropDown != null)
                this.DropDown(this, e);

            PropertyStringDialog dlg = null;

            dlg = new PropertyStringDialog();
            dlg.Font = this.Font;
            dlg.CheckedComboBox = this;
            dlg.Text = this.Caption;
            dlg.PropertyString = this.textBox_text.Text;
            dlg.Items = this.Items;
            dlg.ReturnFirstPart = this.ReturnFirstPart;

            dlg.HideCloseButton = this.HideCloseButton;
            dlg.StartPosition = FormStartPosition.Manual;
            dlg.Location = this.PointToScreen(
                new Point(0,
                0 + this.Size.Height)
                );
            if (this.DropDownWidth == -1)
            {
                int nWidth = this.Width;
                if (dlg.Width < nWidth)
                    dlg.Width = nWidth;
            }
            else
            {
                dlg.Width = this.DropDownWidth;
            }

            if (this.DropDownHeight != -1)
                dlg.Height = this.DropDownHeight;

            dlg.Show(); // 无模式对话框
            // dlg.ShowDialog(this);

            /*
            if (dlg.DialogResult != DialogResult.OK)
                return;
             * */
            try
            {
                while (dlg.IsDisposed == false)
                {
                    Application.DoEvents();
                }
                Thread.Sleep(1);
            }
            catch
            {
            }

            this.textBox_text.Text = dlg.PropertyString;
        }