The following code is not painting anything:
void Form3_Paint(object sender, PaintEventArgs e)
{
string text = new string('m', 3000);
TextRenderer.DrawText(
e.Graphics,
text,
this.Font,
new Point(10, 10),
Color.Black,
Color.Transparent);
}
Seems that the string is too long. If I change the string lenght to 2000 it works (I'm using SegoeUI 9) font.
Do you know any workaround for this?
I try your code block and it painted. So I increment the string length up to 4401. After that my test failed too.
Probably TextRender.DrawText
method has a limitation on string. But I think that this limitation should be depended on machine.
You want to a workaround. So I suggest that Graphics.DrawString
method.
string text = new string('m', 4401);
e.Graphics.DrawString(text,
this.Font,
Brushes.Black,
new Point(0, 0)
);
Edited
Oh! I searched this issue and I found this question on stackoverflow.
TextRenderer doesn't draw a long string
What a coincidence! You asked same issue before 1 year ago.