DrawString doesn't update text / Windows Forms
Hi. I'm new to C# development. I create a control on a form and want to print its ClientRectangle.
Whenever I resize the parent form, OnPaint gets called but text doesn't change. Yet the console message is of course changing. Why it happens?
13 Replies
I should clarify, that the text is getting printed one time, displaying the initial size, but it won't change aftewards
I'd assume you need to use this
because OnDraw seems to only be called when drawing for the first time
and then you'd need to use the Resize event to change whatever you want to change
Whose OnDraw?
The OnPaint is called, that I can see in the console.
I recorded a short video:
https://youtu.be/zeRDKbGyxwU
I recorded one more video with the problem
Could someone have a look at this weird crap?
This is so discouraging. A simple thing doesn't work
If it starts this way then maybe C# or Windows Forms is just no the right tool
after InitializeComponent add
Thanks! I also asked this question on StackOverflow
Stack Overflow
Graphics.DrawString doesn't update text in OnPaint in Windows Forms C#
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()
...
no worries, sometimes it takes time to have time to answer some questions, thankfully yours was detailed enough.
If you have no further questions, please use /close to mark the forum thread as answered