Ejemplo n.º 1
0
        public void Clear()
        {
            while (flpListBox.Controls.Count != 0)
            {
                DetailedListItem item = (DetailedListItem)flpListBox.Controls[0];
                flpListBox.Controls.Remove(item);
                // remove the event hook
                item.EventSelectChanged -= Item_SelectionChanged;
                item.MouseEnter         -= flpListBox_MouseEnter;

                item.Dispose();
            }
            m_CurrentSelected = null;
        }
Ejemplo n.º 2
0
        public void RemoveItem(int _Index)
        {
            DetailedListItem item = (DetailedListItem)flpListBox.Controls[_Index];

            int prevTop = item.Top;// int.MaxValue;
            DetailedListItem newSelected = null;

            item.tmrMouseLeave.Stop();
            item.EventSelectChanged -= Item_SelectionChanged;
            item.MouseEnter         -= flpListBox_MouseEnter;
            if (item.Selected == true)
            {
                if (flpListBox.Controls.Count > _Index + 1)
                {
                    newSelected          = ((DetailedListItem)flpListBox.Controls[_Index + 1]);
                    newSelected.Selected = true;
                }
                else if (_Index - 1 >= 0)
                {
                    newSelected          = ((DetailedListItem)flpListBox.Controls[_Index - 1]);
                    newSelected.Selected = true;
                }
            }
            if (_Index == 0 && flpListBox.Controls.Count > 1)
            {
                flpListBox.Controls[1].Anchor = AnchorStyles.Left | AnchorStyles.Top;
                flpListBox.Controls[1].Width  = flpListBox.Width - (flpListBox.VerticalScroll.Visible == true ? SystemInformation.VerticalScrollBarWidth : 0);
            }
            flpListBox.Controls.Remove(item);
            item.Dispose();
            if (newSelected != null)
            {
                int deltaMove      = newSelected.Top - prevTop;
                int newScrollValue = flpListBox.VerticalScroll.Value + deltaMove;
                if (newScrollValue > flpListBox.VerticalScroll.Maximum)
                {
                    newScrollValue = flpListBox.VerticalScroll.Maximum;
                }
                if (newScrollValue < flpListBox.VerticalScroll.Minimum)
                {
                    newScrollValue = flpListBox.VerticalScroll.Minimum;
                }

                flpListBox.VerticalScroll.Value = newScrollValue;
                flpListBox.PerformLayout();
            }
        }