1
WPF RichTextBox의 삽입 모드를 제어하는 방법을 아는 사람은 누구입니까? RichTextBox를 항상 삽입 모드가 아닌 덮어 쓰기 모드로 강제 설정하려고합니다.WPF RichTextBox에서 삽입 모드를 강제하는 방법
WPF RichTextBox의 삽입 모드를 제어하는 방법을 아는 사람은 누구입니까? RichTextBox를 항상 삽입 모드가 아닌 덮어 쓰기 모드로 강제 설정하려고합니다.WPF RichTextBox에서 삽입 모드를 강제하는 방법
불행하게도이 일을 문서화 방법이있을 것 같지 않습니다. 내가 아는 유일한 방법은 아래와 같이 리플렉션을 사용하는 것입니다.하지만이 기술은 RichTextBox의 내부 동작에 액세스합니다. 현재 버전의 WPF에서 작동하지만 앞으로도 계속 작동 할 것이라는 보장이 없으므로 책임지고 사용하십시오.
PropertyInfo textEditorPropertyInfo = typeof(RichTextBox).GetProperty("TextEditor", BindingFlags.NonPublic | BindingFlags.Instance);
if (textEditorPropertyInfo == null)
throw new NotSupportedException("SetOverwriteable not support on this platform");
object textEditor = textEditorPropertyInfo.GetValue(this, null);
PropertyInfo overtypeModePropertyInfo = textEditor.GetType().GetProperty("_OvertypeMode", BindingFlags.NonPublic | BindingFlags.Instance);
if (overtypeModePropertyInfo == null)
throw new NotSupportedException("SetOverwriteable not support on this platform");
overtypeModePropertyInfo.SetValue(textEditor, true, null);
위의 요구 생성자 후에 발생합니다.