开发者

"Select all" in all textboxes

private void textBox1_MouseClick(object sender, MouseEventArgs e)
        {
            textBox1.SelectAll();
        }

This works but I have 6 textBoxes. Is there any easier way instead of adding event listen开发者_开发技巧ers for each and every textbox? Or a shorthand or something?

Thanks.


Add the same event handler to each and have ((TextBox)sender).SelectAll() to ensure the one that is clicked on is highlighted.

If you're looking for something more generic create a derived class of TextBox containing the same.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜