System.Windows.Forms.TreeView_Old.AddjustScrollViewToSelectedIndex C# (CSharp) Method

AddjustScrollViewToSelectedIndex() public method

public AddjustScrollViewToSelectedIndex ( ) : void
return void
        public void AddjustScrollViewToSelectedIndex()
        {
            if (_selectedIndex < -1)
                _selectedIndex = -1;
            if (_selectedIndex > _list.Count)
                _selectedIndex = _list.Count - 1;
            if (_selectedIndex < _scrollIndex) // Up.
                _scrollIndex = _selectedIndex;
            if (_selectedIndex > _scrollIndex + _renderList.Count - 1) // Down.
                _scrollIndex = _selectedIndex - _renderList.Count + 1;
            _scrollIndex = _scrollIndex < 0 ? 0 : _scrollIndex;
            _scrollIndex = _scrollIndex > _scrollItems - _renderList.Count ? _scrollItems - _renderList.Count : _scrollIndex;
            Refresh();
            
            if (_selectedIndex > -1)
                _list[_selectedIndex].Node.OnClickCall(new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0), _list[_selectedIndex].Node);
        }