我在标点符号后实现了大写。但是如何实现它,用户可以返回并删除第一个单词或字符,因为他想继续小写?
KeyPress(object sender, KeyPressEventArgs e)
{
if(EndOfSentence())
{
e.KeyChar = Char.ToUpper(e.Keychar);
}
}
//
private bool EndOfSentence()
{
//return true if end of sentence found
}
例:如果我写这句话。我不能回去把“我”改成“我”!而且我不能将“A”更改为“a”,但我想!如何编码?
此处的示例项目:http ://www.filefactory.com/file/3ecbn51bhbrv/n/Capi.zip
我看到的唯一解决方案是保存当前和上一个键并检查是否按下了退格键或删除键,例如:
if (!EndOfSentence())
{
previousKeyChar = e.KeyChar;
return;
}
//
if(previousKeyChar.Equals('\b')) return;
else
e.KeyChar = Char.ToUpper(e.KeyChar);
//
//
// And in the EndOfSentence I Check
// if the cursor is at the end of the text
if(textbox1.Text.Length != textbox1.SelectionStart)
return false; //allow editing in the middle of the text