I created the editor inheriting the TextBox.
The editor loads the data from the file like below.
public Editor()
{
this.Text = File.ReadAllText(fileName);
}
The above code works well but the changes of the editor do not apply because not be bound with the file.
In other words, although I change the content of the editor then the changes do not apply to the file.
To do this, I need to write additional code as below.
File.WriteAllText(fileName, content);
The problem is I don't know where to put the above code.
If I put the above code onto the TextChanged
event handler then the performance of the editor is lower.
But I don't know the suitable position to put the above code except for TextChanged
event handler.
Is there a formulaic way to solve this problem?