更新时间:2023-11-09 23:43:58
只需使用 Substring()
方法做一个小技巧:
Just do a trivial trick with Substring()
method:
//KeyPress event handler for your richTextBox
private void richTextBox_KeyPress(object sender, KeyPressEventArgs e){
if(e.KeyChar == ' '){
int i = richTextBox.Text.TrimEnd().LastIndexOf(' ');
if(i != -1) MessageBox.Show(richTextBox.Text.Substring(i+1).TrimEnd());
}
}