Want to improve this question? Add details and clarify the problem by editing this post.
开发者_高级运维Closed 9 years ago.
Improve this questionis there a way in a text box (again web or windows app) that if you type a user-define sequence of characters it will automagically input a string of characters?
for instance, in my web or windows text box, if i'm typing ABC it will enter replace the ABC with The quick brown fox jumped over the lazy dog!
if i understand correctly you can simply register with OnKeyUp event handler of the textbox.
private void textBox_KeyUp(object sender, KeyEventArgs e)
{
string newValue = ChangeUserDefinedSequence(((TextBox)sender).Text);
((TextBox)sender).Text = newValue;
}
and your function to handle the user-defined sequence could look something like this:
private string ChangeUserDefinedSequence(string txtBoxValue)
{
if("ABC".Equals(txtBoxValue))
{
return "The quick brown fox jumped over the lazy dog!";
}
return txtBoxValue;
}
精彩评论