C# richtextbox中加载了如下代码,从第一个字母开始,到最后一个结束,搜索字符串,并设置特殊字符串的颜色

sky-defender 2009-08-27 11:13:19
using System;
using System.Collections;
using System.Runtime.InteropServices;

namespace SmartRunner.Schedule
{
/// <summary>
/// Deprecated. For V1 compatibility only.
/// </summary>
/// <remarks>
/// <p>Scheduler is just a wrapper around the TaskList class.</p>
/// <p><i>Provided for compatibility with version one of the library. Use of Scheduler
/// and TaskList will normally result in COM memory leaks.</i></p>
/// </remarks>
public class Scheduler
{
/// <summary>
/// Internal field which holds TaskList instance
/// </summary>
private readonly TaskList tasks = null;

/// <summary>
/// Creates instance of task scheduler on local machine
/// </summary>
public Scheduler()
{
tasks = new TaskList();
}

/// <summary>
/// Creates instance of task scheduler on remote machine
/// </summary>
/// <param name="computer">Name of remote machine</param>
public Scheduler(string computer)
{
tasks = new TaskList();
TargetComputer = computer;
}

/// <summary>
/// Gets/sets name of target computer. Null or emptry string specifies local computer.
/// </summary>
public string TargetComputer
{
get
{
return tasks.TargetComputer;
}
set
{
tasks.TargetComputer = value;
}
}

/// <summary>
/// Gets collection of system tasks
/// </summary>
public TaskList Tasks
{
get
{
return tasks;
}
}

}
}
...全文
67 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
LixingTie 2009-08-27
  • 打赏
  • 举报
回复

int start = 0;
string findstr = "public";
while (true)
{
start = this.richTextBox1.Find(findstr, start, RichTextBoxFinds.None);
if (start == -1)
break;

this.richTextBox1.Select(start, findstr.Length);
this.richTextBox1.SelectionColor = Color.Blue;
start += findstr.Length;
}

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧