Created
March 6, 2018 15:00
-
-
Save bjoerntx/91cea7efc1d2280bb8b0203ab4bda8f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private bool RemoveEmptyFieldLines() | |
{ | |
foreach (IFormattedText obj in serverTextControl1.TextParts) | |
{ | |
foreach (ApplicationField field in obj.ApplicationFields) | |
{ | |
// check, if character next to empty field is a carriage return | |
if (obj.TextChars[field.Start + field.Length].Char == '\n') | |
{ | |
bool bCompleteLine = | |
(field.Start == obj.Lines.GetItem(field.Start).Start) | |
? true : false; | |
// if yes, remove the field | |
obj.Selection.Start = field.Start; | |
obj.ApplicationFields.Remove(field, false); | |
// if the field is the only text in the line | |
// remove the CR | |
if (bCompleteLine) | |
{ | |
obj.Selection.Length = 1; | |
obj.Selection.Text = ""; | |
} | |
// call RemoveEmptyFieldLines recursively | |
return true; | |
} | |
else | |
field.Text = ""; | |
} | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment