I have a textBox textchanged event:
private void anyTextBox_TextChanged(object sender, EventArgs e)
{
btnUpload.Enabled = txtHost.TextLength > 0 && txtUploadFile.TextLength > 0;
}
And I have a onPaint event:
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Pen penBorder = new Pen(Color.Red, 3);
if (btnUpload.Enabled == false)
{
e.Graphics.DrawRectangle(penBorder, txtHost.Location.X, txtHost.Location.Y,
txtHost.Width - 1, txtHost.Height - 1);
e.Graphics.DrawRectangle(penBorder, txtUploadFile.Location.X, txtUploadFile.Location.Y,
txtUploadFile.Width - 1, txtUploadFile.Height - 1);
}
}
But now when I type text in one of the textboxes depending which one to remove the red rectangle around it and if both textboxes with text remove the red rectangle around both of them.
The problem is that the OnPaint event is being called only once when I'm running the program.