Ejemplo n.º 1
0
        internal AutocompleteListView(RichText tb)
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint, true);
            base.Font    = new Font(FontFamily.GenericSansSerif, 9);
            visibleItems = new List <AutocompleteItem>();
            itemHeight   = Font.Height + 2;
            VerticalScroll.SmallChange = itemHeight;
            BackColor          = Color.White;
            MaximumSize        = new Size(Size.Width, 180);
            toolTip.ShowAlways = false;
            AppearInterval     = 500;
            timer.Tick        += new EventHandler(timer_Tick);

            this.tb = tb;

            tb.KeyDown          += new KeyEventHandler(tb_KeyDown);
            tb.SelectionChanged += new EventHandler(tb_SelectionChanged);
            tb.KeyPressed       += new KeyPressEventHandler(tb_KeyPressed);

            Form form = tb.FindForm();

            if (form != null)
            {
                form.LocationChanged += (o, e) => Menu.Close();
                form.ResizeBegin     += (o, e) => Menu.Close();
                form.FormClosing     += (o, e) => Menu.Close();
                form.LostFocus       += (o, e) => Menu.Close();
            }

            tb.LostFocus += (o, e) => {
                if (!Menu.Focused)
                {
                    Menu.Close();
                }
            };

            tb.Scroll += (o, e) => Menu.Close();
        }