Exemplo n.º 1
0
        public void PageScroll(bool isUp)
        {
            IntPtr direction = (IntPtr)Ul.SB_PAGEDOWN;

            if (isUp)
            {
                direction = (IntPtr)Ul.SB_PAGEUP;
            }
            Ul.SendMessage2(this.Handle, Ul.WM_VSCROLL, direction, IntPtr.Zero);
        }
Exemplo n.º 2
0
        public void ScrollSelectedToCenter()
        {
            Rectangle rect              = this.GetItemRectangle(this.SelectedIndex);
            int       selectedOrder     = (int)((rect.Y + rect.Height) / rect.Height) - 1;
            int       visibleItemsCount = GetVisibleCount();
            int       scrollCount       = 0;
            // определим направление
            IntPtr direction = (IntPtr)Ul.SB_LINEUP;

            if (selectedOrder < visibleItemsCount / 2)
            {
                scrollCount = visibleItemsCount / 2 - selectedOrder;
            }
            else
            {
                direction   = (IntPtr)Ul.SB_LINEDOWN;
                scrollCount = selectedOrder - visibleItemsCount / 2;
            }
            for (int i = 0; i < scrollCount; ++i)
            {
                Ul.SendMessage2(this.Handle, Ul.WM_VSCROLL, direction, IntPtr.Zero);
                //                Console.WriteLine(selectedOrder.ToString() + " -> " + scrollCount.ToString());
            }
        }