TX 常用的文字处理功能1-查找和替换

发布时间:2013/04/23 00:04 发布者:iceman

返回博客中心

作为选择文本的替代方法,TextControl.Find 方法可以用于定位指定文本。在本示例中,我们将查找文字,并且更改文字的样式。

在本示例中,我们将查找文字,并且更改文字的样式。

代码如下:

        [C#] 
        textControl1.Text = "TX Text Control"; 
        textControl1.Find(""查找和替换", 0, TXTextControl.FindOptions.MatchCase"); 
        textControl1.Selection.FontSize = 400; 

        [Visual Basic] 
        TextControl1.Text = "TX Text Control" 
        TextControl1.Find("查找和替换", 0, TXTextControl.FindOptions.MatchCase) 
        TextControl1.Selection.FontSize = 400 

        [Delphi] 
        TextControl1.Text := 'TX Text Control'; 
        TextControl1.Find('查找和替换', 0, TXTextControl.FindOptions.MatchCase); 
        TextControl1.Selection.FontSize := 400;
 

效果图:

 

同时,你也可以在选择时替换该文本,代码如下:

        [C#] 
        textControl1.Find("查找和替换", 0, TXTextControl.FindOptions.MatchCase);
        textControl1.Selection.FontSize = 400;
        textControl1.Selection.Text = "Find And Replace";

        [Visual Basic] 
        TextControl1.Text = "TX Text Control" 
        TextControl1.Find("查找和替换", 0, TXTextControl.FindOptions.MatchCase) 
        TextControl1.Selection.Text = "Find And Replace" 

        [Delphi] 
        TextControl1.Text := 'TX Text Control'; 
        TextControl1.Find('查找和替换', 0, TXTextControl.FindOptions.MatchCase); 
        TextControl1.Selection.Text := 'Find And Replace';
 
 

示例代码:

VS2010 && Framework 4.0 && TX TextControl X8 SP1

TXFinedAndReplace.zip (41.64 kb)


关于葡萄城

赋能开发者!葡萄城是专业的集开发工具、商业智能解决方案、低代码开发平台于一身的软件和服务提供商,为超过 75% 的全球财富 500 强企业提供服务。葡萄城专注控件软件领域30年,希望通过模块化的开发控件、灵活的低代码应用开发平台等一系列开发工具、解决方案和服务,帮助开发者快速响应复杂多变的业务需求,最大程度地发挥开发者的才智和潜能,让开发者的 IT 人生更从容更美好。

了解详情,请访问葡萄城官网