Bu benim Rect sınıfını kullanarak ilgili olmadığını ne yaptığını Geçerli dizgenin belirlenen sınırlardan daha büyük olup olmayacağı. Öyleyse yazdım. Aksi takdirde buna eklemeye devam ettim.
foreach (string field in temp)
{
if (field == string.Empty)
{
continue;
}
else
{
tempSB.Clear();
tempSB.Append(sb.ToString());
tempSB.Append(field).Append(", "); //append the incoming value to SB for size testing
if (gfx.MeasureString(tempSB.ToString(), defaultFont).Width > 500) //if the incoming string is bigger than the right bounds, write it and clear SB
{
gfx.DrawString(sb.ToString(), defaultFont, blackBrush, 50, currentLine + defaultSpacing);
currentLine += 15;
sb.Clear();
sb.Append(" " + field).Append(","); //add the overflow to the beginning of the next line
}
else
{
sb.Append(field).Append(", "); //if it is not too big, append it
}
}
}
if (sb.Length > 0 && sb[sb.Length - 1] == ',') sb.Length--;
gfx.DrawString(sb.ToString(), defaultFont, blackBrush, 50, currentLine + defaultSpacing); //write out whatever has not already been written out
Biliyorum bu soruya geç kaldım ama umarım birilerine yardımcı olabilir.
Eğer bir çeşit konsol kipi ise DrawString() öğesini iki kez çağırmaktan bahsediyorsunuz? – BlackBear
Üzgünüm Bunu anlamadım mı? –
Yazdırmak istediğiniz her satır için DrawString() öğesini çağırmayı deneyin, örneğin DrawString (Project No "); DrawString (textBoxProj .....); – BlackBear