G
gilbert@gmail
Hello.
I have a question about OnPaint override.
For example, if i have the following code in my inherited form class,
private Brush _brush = Brushes.Black;
private RectangleF _rect = new RectangleF(0,0,100,100);
private int counter =0;
protected override void OnPaint(PaintEventArgs e){
if (counter==0){
counter++;
e.Graphics.Clear(Color.White);
e.Graphics.DrawString("Test", this.Font, _brush, _rect);
}
}
I expect the OnPaint method will do nothing after the first call. That
means, the string "Test" should stay on screen if the form is not
resized/moved/covered by other windows. However, in
reality, the OnPaint do the e.Graphics.Clear() automatically.
I'd like to know if that is possible for me to stop that behavior. In
my application, my form contains many individual text strings. The
strings are updated periodically individually. I would like to render
the updated strings only, not rendering the whole thing for every
string update. Thank you very much for your help!
Gilbert
I have a question about OnPaint override.
For example, if i have the following code in my inherited form class,
private Brush _brush = Brushes.Black;
private RectangleF _rect = new RectangleF(0,0,100,100);
private int counter =0;
protected override void OnPaint(PaintEventArgs e){
if (counter==0){
counter++;
e.Graphics.Clear(Color.White);
e.Graphics.DrawString("Test", this.Font, _brush, _rect);
}
}
I expect the OnPaint method will do nothing after the first call. That
means, the string "Test" should stay on screen if the form is not
resized/moved/covered by other windows. However, in
reality, the OnPaint do the e.Graphics.Clear() automatically.
I'd like to know if that is possible for me to stop that behavior. In
my application, my form contains many individual text strings. The
strings are updated periodically individually. I would like to render
the updated strings only, not rendering the whole thing for every
string update. Thank you very much for your help!
Gilbert