public Insert ( int offset, string value ) : int | ||
offset | int | |
value | string | |
return | int |
// Get the TextEditorData object TextEditorData data = textEditor.Data; // Insert text at the start of the document data.Insert("Hello, world!\n", 0);
// Get the TextEditorData object TextEditorData data = textEditor.Data; // Get the current cursor position int cursorPosition = data.Cursor.Offset; // Insert text at the current cursor position data.Insert("Hello, world!\n", cursorPosition);In this example, the Insert method is used to insert the text "Hello, world!\n" at the current cursor position. The cursor position is determined using the Cursor property of the TextEditorData class. Package library: Mono.TextEditor.dll Overall, the TextEditorData class is a useful tool for text manipulation in a C# desktop application. The Insert method specifically allows for easy insertion of text at a desired location.