C# TextBox全选

        #region-----画面のテキストボックスの全選択処理-----
        /// <summary>
        /// 画面のテキストボックスの全選択処理
        /// </summary>
        /// <param name="crol"></param>
        public static void TextBoxEnter_SelectAll(Control crol)
        {
            System.Windows.Forms.TextBox txtBox = new System.Windows.Forms.TextBox();
            foreach (Control con in crol.Controls)
            {
                if (con is System.Windows.Forms.TextBox)
                {
                    txtBox = (System.Windows.Forms.TextBox)con;
                    txtBox.Enter += (EventHandler)delegate(object sender, EventArgs e)
                    {
                        ((TextBox)sender).SelectAll();
                    };
                }
                if (con.Controls.Count > 0)
                {
                    TextBoxEnter_SelectAll(con);
                }
            }
        }
        #endregion

  

猜你喜欢

转载自www.cnblogs.com/-jwj/p/11760884.html