I just saw an interesting support request by reviewing the solved cases in our support department. A customer wanted to know how to remove a page number field in a header or footer by clicking on it.

From our documentation:

The PageNumberField class represents a field in a header or footer of a Text Control document that automatically displays the current page number. The class inherits all properties and methods from the TextField class.

Due to the fact that the PageNumberField is derived from the TextField base class, it's events can be used as well. The TextFieldClicked event returns the clicked TextField.

If the user clicks on a PageNumberField, this event is fired as well. To access the properties of the PageNumberField, you need to cast the returned field to the derived type:

private void textControl1_TextFieldClicked(object sender, TXTextControl.TextFieldEventArgs e)
    TXTextControl.PageNumberField myField = (TXTextControl.PageNumberField)e.TextField;

This approach is possible with all derived TextField types like ApplicationField, DocumentTarget or DocumentLink.