PDA

View Full Version : Find/Replace using .net version


Unregistered
December 3, 2002, 01:27:09
I have loaded a .rtf document into the new TXTextControl .net version. This document contains "markers" that will be replaced with values from an array.

For example, -|25|- will be replaced with the 25th item in the array.

I have found the Find method will accept a text string to "Find" the marker but the Replace method opens a dialogue box.

How do I Find and Replace the marker without user interaction?

This will also need to be done with markers located in the header and footer of the .rtf document.

How do I activate the header (and footer) so I can Find and Replace these markers?


This message was originally posted by Chuck Hildenbrand in the old TX Text Control Support Forum.

Björn Meyer
December 3, 2002, 12:21:07
Hello Chuck

You can use the Find method to search for a given string. This string will be selected by TX Text Control. This selection can be replaced using the Selection.Text property.

The HeaderFooter.Activate method actives a specified part of the TX Text Control document. After that you can search for strings using the Find method in a header or a footer.

Björn Meyer, TX Text Control


This message was originally posted by Björn Meyer in the old TX Text Control Support Forum.

Unregistered
December 6, 2002, 20:56:21
Bjorn,

This is great. I am able to use the Find method to locate specific text, select the text by using Select and then replacing the text by using Selection.Text:

Dim strText As String
Dim intText, intLen As Integer

intLen = txtFind.Text.Length
intText = TextControl1.Find("Text string")
TextControl1.Select(intText, intLen)
TextControl1.Selection.Text = "NEW TEXT"

The above code selects the text "Text string" in the body of the document and replaces it with "NEW TEXT".

Now I'm trying to programatically activate the header. Although the HeaderFooter.Activate method shows up in Object Browser, IntelliSense does not expose the activate method. If I enter:

"TXTextControl.HeaderFooter.Activate" the following error is displayed:

"Reference to a non-shared member requires an object reference".

What am I doing wrong?

Chuck


This message was originally posted by Chuck Hildenbrand in the old TX Text Control Support Forum.

DarylBlowes
October 22, 2006, 15:39:40
You have to choose what header or footer you want to activate:

Me.txtMain.HeadersAndFooters.GetItem(TXTextControl .HeaderFooterType.Footer).Activate()

My question is how do you activate the Body of the document after you have activated a header or footer?
...
I guess the Deactivate() method on the headers will shift back to the body???

Gunnar Giffey
October 23, 2006, 09:03:28
My question is how do you activate the Body of the document after you have activated a header or footer?
Hello Daryl,
This can be done using textControl1.HeadersAndFooters.GetItem(TXTextContr ol.HeaderFooterType.Header).Deactivate();