2012-04-22 50 views
0

嗯,我試圖創建標籤彼此相鄰,但取決於用戶輸入它可以重疊旁邊的標籤。我在想,如果他們的某種屬性,不讓標籤重疊..我試過AutoSize = true方法,但我沒有運氣如何停止動態添加的標籤重疊

的信息是從XML文件中讀取 - 他們水平重疊

if (textReader.Name == "test") 
{ 
    textReader.Read(); 
    XmlNodeType nType = textReader.NodeType; 

    if (nType == XmlNodeType.Text) 
    { 
     Label l = new Label(); 

     System.Drawing.Point l1 = new System.Drawing.Point(15, 48 + a); 
     l.Location = l1; 
     l.Text = textReader.Value.ToString(); 
     l.Size = new Size(200, 50); 

     tabPage2.Controls.Add(l); 
     a += 35; 
    } 
} 
+0

你的意思是橫向彼此相鄰將去下一行? – Coder 2012-04-22 12:37:45

+0

是的,我很抱歉不清楚 – Hashey100 2012-04-22 12:39:06

回答

2

您可以根據文本和MaximumSize使用AutoSize調整寬度和高度自動換行文本,其餘文本如果寬度超過200

l.AutoSize = true; 
l.MaximumSize = new Size(200, 50); 
+0

thanx做到了 – Hashey100 2012-04-22 13:04:45