Sorry if I ask something simple. I asked in Discord and IRC and for two days nobody has provied a solution.
I have the following form:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.FillRectangle(Brushes.Black, ClientRectangle);
Console.WriteLine($"OnPaint: {ClientRectangle}");
e.Graphics.DrawString($"{ClientRectangle}", Font, Brushes.White, ClientRectangle);
}
}
When I run it, I see a black rectangle and a text above it with the coordinates.
However, when I’m resizing the form and I see a bunch of “OnPain: …” messages (which indicates that my OnPaint is being called) the initial text never changes.
What is going on here really?
I uploaded my source code here: https://github.com/OnkelTem/CSharpDrawStringIssue
I also recorded two videos:
- https://www.youtube.com/watch?v=zeRDKbGyxwU
- https://www.youtube.com/watch?v=AzqtWy6flsk