开发者

shortcut to display long predefined string [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.

Want to improve this question? Add details and clarify the problem by editing this post.

开发者_高级运维

Closed 9 years ago.

Improve this question

is 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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜