问两个小问题 在WINFORM中如果实现 鼠标选中一行文字中的一小段儿文字 然后提取出来?如何实现关键字变色?假如我在TEXTBOX里输入一行文字。当里面有Csdn的时候 我就让他显示为蓝色。 如果有.NET 我就让他显示为红色。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在你的form里面 好办你可以用RichTextBox 来显示问题 判断用户选中 文字 将文字属性设置为 某种颜色如果为CSDn 的话 用正则判断 参考http://www.aspx2.com/a/WinForm/2010/0528/42360.html SendTxtMessage(hwdText, WM_SETTEXT, 0, strText.ToCharArray());IDataObject iData = Clipboard.GetDataObject();if (null != iData){ if (iData.GetDataPresent(DataFormats.Text))) { selectedText += (String)iData.GetData(DataFormats.Text); } }int index = richTextBox1.Text.IndexOf('\n', start);while (index > -1){ richTextBox1.Select(start, index - start); setColor(count); count++; start = index + 1; index = richTextBox1.Text.IndexOf('\n', start);}private void setColor(int lines){ richTextBox1.SelectionColor = Color.Blue;} 参考这里的源代码就可以了。注意要先注册为codeproject网站的用户,只需要一个邮箱地址就可以注册了,挺方便的,而且上面有很多好歹么。RichTextBox with background highlighting in VB.NET richTextBox1.SelectionColor = 你所设定的颜色 richTextBox1.Select(startIndex, length);richTextBox1.SelectionColor = color; 如果实现 鼠标选中一行文字中的一小段儿文字 然后提取出来?How to Realize it 恩codeproject上有不少这样的例子不过也可以简单点,直接使用现成的控件,比如QWhale.Editor控件 |ZYCWPF| 在WCF服务器中双工回调一个ImageSource对像用MVVM方式赋值后报错:必须在相同的线程上创建 DependencySource 请问,ReadLine方法读取文件 新手 自定义控件实现拖拽 如何执行一串DOS命令? 急急急急急急急急急急急急急急急急急急急!!在线等!!快要下岗了 我的面试题,大家来做做看吧.?? DataTable加工后添加行列,输出求和,百分比的问题请教! 单选按钮是否被选中??? C#中如何使用随机函数?(高手请帮忙) 指数的表示法(求助) 急 ,C#的Treeview事件
http://www.aspx2.com/a/WinForm/2010/0528/42360.html
IDataObject iData = Clipboard.GetDataObject();
if (null != iData)
{
if (iData.GetDataPresent(DataFormats.Text)))
{
selectedText += (String)iData.GetData(DataFormats.Text);
}
}int index = richTextBox1.Text.IndexOf('\n', start);
while (index > -1)
{
richTextBox1.Select(start, index - start);
setColor(count);
count++;
start = index + 1;
index = richTextBox1.Text.IndexOf('\n', start);
}
private void setColor(int lines)
{
richTextBox1.SelectionColor = Color.Blue;
}
注意要先注册为codeproject网站的用户,只需要一个邮箱地址就可以注册了,挺方便的,而且上面有很多好歹么。RichTextBox with background highlighting in VB.NET
richTextBox1.SelectionColor = color;
How to Realize it