コード例 #1
0
        private void item_MouseClick(object sender, MouseEventArgs e)
        {
            QQComboBoxItem ci = sender as QQComboBoxItem;

            Texts       = ci.Texts;
            SelectIndex = int.Parse(ci.Name.Substring(13));
            SelectItem  = SelectText = ci.Texts;
            this.Height = 26;
            showed      = false;
            OnMouseLeave(null);
        }
コード例 #2
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            this.Focus();
            this.Leave += new EventHandler(p_Leave);
            img         = ResClass.GetImgRes("login_inputbtn_down");
            if (Items != null)
            {
                p            = new Panel();
                p.Left       = 2;
                p.Top        = 24;
                p.Width      = this.Width - 5;
                p.Height     = Items.Length * 20;
                p.AutoScroll = true;

                p.Focus();
                p.Leave += new EventHandler(p_Leave);

                bool isScroll = false;

                int maxHeight = this.Parent.Height - this.Top - 24;
                int h         = 20 * Items.Length + 5;
                if (h > maxHeight)
                {
                    isScroll = true;
                }
                else
                {
                    isScroll = false;
                }

                for (int i = 0; i < Items.Length; i++)
                {
                    QQComboBoxItem item = new QQComboBoxItem();
                    item.Name  = "qqcomboBoxItem_" + i;
                    item.Texts = Items[i];
                    item.Left  = 0;
                    item.Top   = 20 * i;
                    if (isScroll)
                    {
                        item.Width = p.Width - 20;
                    }
                    else
                    {
                        item.Width = p.Width;
                    }
                    item.Height      = 20;
                    item.MouseClick += new MouseEventHandler(item_MouseClick);
                    p.Controls.Add(item);
                }
                this.Controls.Add(p);
                if (this.Height == 26)
                {
                    if (isScroll)
                    {
                        this.Height += 20 * (maxHeight / 20) + 5;
                        p.Height     = 20 * (maxHeight / 20);
                    }
                    else
                    {
                        this.Height += h;
                        p.Height     = h - 5;
                    }
                    showed = true;
                }
                else
                {
                    this.Height = 26;
                    p.Height    = 0;
                    showed      = false;
                    p.Controls.Remove(p);
                    p.Dispose();
                }
                ControlCollection cce = this.Parent.Controls;
                for (int i = 0; i < cce.Count; i++)
                {
                    if (cce[i] is BasicComboBox && !cce[i].Name.Equals(this.Name))
                    {
                        (cce[i] as BasicComboBox).CloseListPanel();
                    }
                }
            }
            this.BringToFront();
            this.Invalidate();
        }