This is something that I've hated for years, but want to see if anyone else has figured out a way around this.
If I have a textbox that has text in it and it has properties like Font, Line Spacing, etc applied to it. When I use the api to change the text (objTextbox.Text = "LINE 1" & vbNewLine & "LINE 2") it sets all of the properties back to the default values.
This is similar to if you were to clear a textbox in the SE GUI. However, if in the SE GUI you select all of the text and immediately start typing to replace it, it will keep your settings. I think this has to do with Solid Edge actually applying certain properties to text and not the textbox. So if the text is gone, all of the properties are gone. However, I don't understand why when I am just changing the value through the API it acts like it cleared the field first and then added the text, versus replacing only text and keeping the properties.
Thank you for the reply.
I used the Characters property in this snippet to test and I still get the same behavior.
objTextEdit = objTextBox.Edit objTextEdit.SetSelect(0, objTextBox.Text.Length, SolidEdgeFrameworkSupport.TextSelectConstants.seTextSelectAll) objTextEdit.Characters = strText
Do you have any suggestions?
I think the trick was not to select all text by leaving the last character unselected, set the new text and then select the last character and set it to an empty string.
You can try saving the "Font","LineSpacing","IsItalic"etc. properties of the current text and then apply the same properties while updating the new Text on textbox.
SolidEdgeFrameworkSupport.TextBox seTextBox = seTextBoxes.Item(t);
SolidEdgeFrameworkSupport.TextEdit txtEdit = seTextBox.Edit;
bool isBold= txtEdit.Bold;
bool isItalic = txtEdit.Italic;
string font= txtEdit.Font;
txtEdit.Characters = "NewCharacter";
txtEdit.Bold = isBold;
txtEdit.Italic = isItalic;
txtEdit.Font = font;
This is not an ideal approach to modify text but still this can be treated as workaround.
Let me know whether it will help you.