/// <summary>
        ///  TextBox根据文本长度自动扩大宽度
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            Graphics g = this.textBox1.CreateGraphics();
            System.Drawing.SizeF s = g.MeasureString(this.textBox1.Text, this.textBox1.Font);
            this.textBox1.Width = (int)s.Width + 3;
        }

 

 posted on 2012-11-19 11:35  纳米程序员  阅读(677)  评论(0编辑  收藏  举报