如何用c#代码实码单击文本框后改变该文本框的颜色,其它的不变 5
3个回答
展开全部
重写TextBox
/// <summary>
/// 进入
/// </summary>
/// <param name="e"></param>
protected override void OnEnter(EventArgs e)
{
base.OnEnter(e);
{
this.BackColor = Color.FromArgb(255, 255, 225);
this.ForeColor = Color.Black;
}
}
/// <summary>
/// 离开事件
/// </summary>
/// <param name="e"></param>
protected override void OnLeave(EventArgs e)
{
base.OnLeave(e);
{
this.ForeColor = Color.Black;
this.BackColor = SystemColors.Window;
}
}
/// <summary>
/// 进入
/// </summary>
/// <param name="e"></param>
protected override void OnEnter(EventArgs e)
{
base.OnEnter(e);
{
this.BackColor = Color.FromArgb(255, 255, 225);
this.ForeColor = Color.Black;
}
}
/// <summary>
/// 离开事件
/// </summary>
/// <param name="e"></param>
protected override void OnLeave(EventArgs e)
{
base.OnLeave(e);
{
this.ForeColor = Color.Black;
this.BackColor = SystemColors.Window;
}
}
展开全部
private void textBox1_Click(object sender, EventArgs e)
{
Random rd = new Random();
int i = rd.Next(0, 255);
int j = rd.Next(0, 255);
int k = rd.Next(0, 255);
this.textBox1.BackColor = Color.FromArgb(i, j, k);
}
{
Random rd = new Random();
int i = rd.Next(0, 255);
int j = rd.Next(0, 255);
int k = rd.Next(0, 255);
this.textBox1.BackColor = Color.FromArgb(i, j, k);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
private void Form10_Paint(object sender, PaintEventArgs e)
{
Rectangle rc = textBox1.Bounds;
rc.X -= 1; rc.Y -= 1;
rc.Inflate(1, 1);
e.Graphics.DrawRectangle(Pens.Red, rc);
}
{
Rectangle rc = textBox1.Bounds;
rc.X -= 1; rc.Y -= 1;
rc.Inflate(1, 1);
e.Graphics.DrawRectangle(Pens.Red, rc);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询