Пример #1
0
        /// <summary>
        /// vertical table scroll
        /// </summary>
        /// <param name="scrollEventType">Scroll Event Type</param>
        /// <param name="newPos">the new position</param>
        /// <param name="oldPos">the old position</param>
        /// <param name="scrollWindow">true, if we need to scroll the window right away</param>
        protected override void ScrollVertically(ScrollEventType scrollEventType, int newPos, int oldPos, bool scrollWindow)
        {
            NativeScroll.SCROLLINFO sc = ScrollInfo(NativeScroll.SB_VERT);
            int maxScroll = sc.nMax - sc.nPage + 1;

            if (newPos > maxScroll)
            {
                newPos = maxScroll;
            }
            if (newPos < 0)
            {
                newPos = 0;
            }

            NativeScroll.SetScrollPos(this.Handle, NativeScroll.SB_VERT, newPos, true);

            _topIndex = newPos - RecordsBeforeCurrentView;

            if (scrollWindow)
            {
                NativeWindowCommon.RECT rc = new NativeWindowCommon.RECT();
                rc.top    = ClientRectangle.Top + _header.Height;
                rc.left   = ClientRectangle.Left;
                rc.right  = ClientRectangle.Right;
                rc.bottom = ClientRectangle.Bottom;
                NativeScroll.ScrollWindowEx(this.Handle, 0, (oldPos - newPos) * RowHeight, ref rc, (IntPtr)null, (IntPtr)null, (IntPtr)null, 0);
            }
            base.ScrollVertically(scrollEventType, newPos, oldPos, scrollWindow);
        }
Пример #2
0
        /// <summary>
        /// perform horizontal scroll
        /// </summary>
        /// <param name="value"></param>
        /// <param name="newValue"></param>
        private void ScrollHorizontally(int value, int newValue)
        {
            NativeScroll.SCROLLINFO sc = ScrollInfo(NativeScroll.SB_HORZ);
            int maxValue = sc.nMax - sc.nPage;

            if (newValue < 0)
            {
                newValue = 0;
            }
            if (newValue > maxValue)
            {
                newValue = maxValue;
            }
            NativeScroll.SetScrollPos(this.Handle, NativeScroll.SB_HORZ, newValue, true);
            NativeWindowCommon.RECT rc = new NativeWindowCommon.RECT();
            NativeScroll.ScrollWindowEx(this.Handle, value - newValue, 0, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero,
                                        ref rc, NativeScroll.SW_SCROLLCHILDREN | NativeScroll.SW_INVALIDATE | NativeScroll.SW_ERASE);
            _corner.X = getXCorner();
        }