سؤال

I want to detect a text in my label is single or multiline. Can I do it in a more plain way than

TextRenderer.MeasureText(label.Text, font, label.Size).Height > TextRenderer.MeasureText("a", font).Height
هل كانت مفيدة؟

المحلول

No, you can't. Only "cheat" ways like your.
E.g.

bool multiline = label.Height - label.Padding.Top - label.Padding.Bottom > label.Font.Size*2;
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top