c# - RichTextBox: Delete entire run if any chars within it are deleted? -


i'm working on control allows user add selected keywords drop-down richtextbox. keywords inserted individual (and named) runs. there list of 8 can choose from. there ability add free text around inserted words. need able delete entire keyword (run) if user deletes character within it. so, if user backspaces in last character of keyword (run) entire keyword removed - otherwise back-end code interprets keywords break. better keyword gone messed up! apply if selected text ends halfway through keyword (run). entire keyword has go.

my thinking if keyword part of "run" have check each char involved in keypress or selection runs of chars belong to, , delete entire runs. i'm not sure if i'm working towards best idea/solution though, or how it.

example: there alert @ [location] involving unit [name]

if backspace hit "]" entire keyword (run) needs go. if select text like: "tion] involving unit [name]" - both keywords (runs) have go, , rest of text remains. there slim chance may use same keword more once, need handled individually.

any c# solutions or advice appreciated.


Comments