日期:2014-05-18 浏览次数:21315 次
/// <summary> /// 窗体加载事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Form1_Load(object sender, EventArgs e) { foreach (object obj in panel1.Controls) { if (obj is TextBox) { ((TextBox)obj).MouseClick += new MouseEventHandler(TextBox_MouseClick); //给panel1控件中每个文本框订阅 Enter 事件 } } } /// <summary> /// 文本框的鼠标单击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TextBox_MouseClick(object sender, MouseEventArgs e) { ((TextBox)sender).SelectionStart = ((TextBox)sender).Text.Length; }