유사한 예가 Here으로 주어졌다. 또한 그들은 maxLength 문제를 msdn
에 처리했습니다. 중요 : 기사에서 MaxLength가 어떻게 사용되는지보십시오. 내가 전에이 문제 들었어요
private static void DrawALineOfText(PaintEventArgs e)
{
// Declare strings to render on the form.
string[] stringsToPaint = { "Tail", "Spin", " Toys" };
// Declare fonts for rendering the strings.
Font[] fonts = { new Font("Arial", 14, FontStyle.Regular),
new Font("Arial", 14, FontStyle.Italic),
new Font("Arial", 14, FontStyle.Regular) };
Point startPoint = new Point(10, 10);
// Set TextFormatFlags to no padding so strings are drawn together.
TextFormatFlags flags = TextFormatFlags.NoPadding;
// Declare a proposed size with dimensions set to the maximum integer value.
Size proposedSize = new Size(int.MaxValue, int.MaxValue);
// Measure each string with its font and NoPadding value and
// draw it to the form.
for (int i = 0; i < stringsToPaint.Length; i++)
{
Size size = TextRenderer.MeasureText(e.Graphics, stringsToPaint[i],
fonts[i], proposedSize, flags);
Rectangle rect = new Rectangle(startPoint, size);
TextRenderer.DrawText(e.Graphics, stringsToPaint[i], fonts[i],
startPoint, Color.Black, flags);
startPoint.X += size.Width;
}
}
Source
, 그것은 윈도우 버그입니다. 이런 종류의 미친 짓 할 때 존재하는 종류. 해결 방법은 매우 명확합니다. 문자열에 1000자를 넘는 문자열이 포함되어 있으면 문자열이 얼마나 넓은 지 신경 쓰지 않아도 결코 맞지 않습니다. –