Change the borderColor of the TextBox

2019-01-11 01:44发布

How can I change the BorderColor of the Textbox when a user Clicks on it or focuses on it?

7条回答
We Are One
2楼-- · 2019-01-11 02:09

set Text box Border style to None then write this code to container form "paint" event

private void Form1_Paint(object sender, PaintEventArgs e)
        {
System.Drawing.Rectangle rect = new Rectangle(TextBox1.Location.X, TextBox1.Location.Y, TextBox1.ClientSize.Width, TextBox1.ClientSize.Height);

                rect.Inflate(1, 1); // border thickness
                System.Windows.Forms.ControlPaint.DrawBorder(e.Graphics, rect, Color.DeepSkyBlue, ButtonBorderStyle.Solid);

}
查看更多
登录 后发表回答