找回密码
 立即注册

QQ登录

只需一步,快速开始

ninja_aya

中级会员

54

主题

197

帖子

561

积分

中级会员

积分
561

活字格认证

ninja_aya
中级会员   /  发表于:2015-6-30 11:43  /   查看:3801  /  回复:2
目前想实现这样一个功能,文章分为多个章节,每个章节占有那些section我是可以获取到比如
第一章 1-3个section
第二章 4-7 section
。。。。
现在想删除第二章4-7的section
请问如何实现。

2 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2015-6-30 17:39:00
沙发
回复 1楼ninja_aya的帖子

移除 Section 的方法如下,删除特定Section 需要略微修改:

  1. private void RemoveAllSections()
  2. {
  3.     TXTextControl.SectionCollection.SectionEnumerator sectionEnum = textControl1.Sections.GetEnumerator();
  4.     int sectionCounter = textControl1.Sections.Count;

  5.     sectionEnum.Reset();
  6.     sectionEnum.MoveNext();
  7.     for (int i = 0; i < sectionCounter; i++)
  8.     {
  9.         TXTextControl.Section curSection = (TXTextControl.Section)sectionEnum.Current;

  10.         if (curSection.Number == 1)
  11.         {
  12.             sectionEnum.MoveNext();
  13.             continue;
  14.         }

  15.         textControl1.Selection.Start = curSection.Start - 2;
  16.         textControl1.Selection.Length = 1;
  17.         textControl1.Selection.Text = "";
  18.     }
  19. }
复制代码
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2015-7-17 17:32:00
板凳
回复 1楼ninja_aya的帖子

为了给你提供更优质的服务,请对本次服务进行评分。我们会认真对待你提出的宝贵意见,谢谢   

评分

参与人数 1满意度 +5 收起 理由
ninja_aya + 5 谢谢,问题解决

查看全部评分

回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部