DevExpress RichEditControl 上下翻页功能 z

/// <summary>

        /// 翻页

        /// </summary>

        /// <param name="isPre"></param>

        public void PageSelect(bool isPre)

        {

            richEditControl1.Document.ChangeActiveDocument(richEditControl1.Document);

            int currentPageIndex = ((DevExpress.XtraRichEdit.PageBasedRichEditView)richEditControl1.ActiveView).CurrentPageIndex;//获取当前的页面Index

            LayoutPage page;

            if (isPre)

            {

                if (currentPageIndex == )

                    return;

                page = richEditControl1.DocumentLayout.GetPage(currentPageIndex - );

            }

            else

            {

                if (currentPageIndex == richEditControl1.DocumentLayout.GetPageCount() - )

                    return;

                page = richEditControl1.DocumentLayout.GetPage(currentPageIndex + );

            }

            ScrollToPosition(page.MainContentRange.Start);

        }

        /// <summary>

        /// 滚动指定位置

        /// </summary>

        /// <param name="position"></param>

        void ScrollToPosition(int position)

        {

            richEditControl1.Document.CaretPosition = richEditControl1.Document.CreatePosition(position);

            richEditControl1.ScrollToCaret(0.5f);

        }
/// <summary>

        /// 翻页

        /// </summary>

        /// <param name="isPre"></param>

        public void PageSelect(bool isPre)

        {

            if (isPre)

            {

                PreviousPageCommand prePage = new PreviousPageCommand(richEditControl1);

                prePage.CreateDefaultCommandUIState();

                prePage.Execute();

            }

            else

            {

                NextPageCommand nextPage = new NextPageCommand(richEditControl1);

                nextPage.CreateDefaultCommandUIState();

                nextPage.Execute();

            }

}

DevExpress RichEditControl 上下翻页功能 z

上一篇:AS3舞台的大小,可视区域大小及SWF文件的原始尺寸大小


下一篇:使用DateTime的ParseExact方法实现特殊日期时间的方法详解(转)