zoukankan      html  css  js  c++  java
  • 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 == 0)
    
                        return;
    
                    page = richEditControl1.DocumentLayout.GetPage(currentPageIndex - 1);
    
                }
    
                else
    
                {
    
                    if (currentPageIndex == richEditControl1.DocumentLayout.GetPageCount() - 1)
    
                        return;
    
                    page = richEditControl1.DocumentLayout.GetPage(currentPageIndex + 1);
    
                }
    
                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();
    
                }
    
    }

    GIF1.gif

  • 相关阅读:
    CCF CSP 题解
    CCF CSP 2019032 二十四点
    CCF CSP 2018121 小明上学
    CCF CSP 2019092 小明种苹果(续)
    CCF CSP 2019091 小明种苹果
    CCF CSP 2019121 报数
    CCF CSP 2019031 小中大
    CCF CSP 2020061 线性分类器
    CCF CSP 2020062 稀疏向量
    利用国家气象局的webservice查询天气预报(转载)
  • 原文地址:https://www.cnblogs.com/zeroone/p/6589342.html
Copyright © 2011-2022 走看看