作为选择文本的替代方法,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';

