2012-12-01 90 views
0

如何設置動態添加標籤 我在哪裏在串得到標籤的名稱變量 一個標籤在面板如何設置動態添加標籤的文本對齊

Dim instance As New Label 
    Dim stringVariable As String 

動態添加上形式負載的文本對齊事件::

instance.Location = New Point(15, 15) 
    instance.Size = New Size(60, 30) 
    instance.BorderStyle = BorderStyle.FixedSingle 
    instance.AutoSize = False 
    instance.Text = "LABEL1" 
    Me.Panel1.Controls.Add(instance) 

我被越來越名稱:

for each c as control in Panel1.Controls 
    stringVariable=c.name 
    next 

但它不可能

Me.Panel1.Controls(stringVariable).textalign ?????? 
    it does not show text align property 

請幫助

回答

2
DirectCast(Me.Panel1.Controls("Label1"), Label).TextAlign = ContentAlignment.TopRight 
+0

三江源非常 – Dandy

0

我發現,這些值將請將textAlign

Public pTop_Center As Long = 2 
Public pMiddle_Center As Long = 32 
Public pBotton_Center = 512 

btn.TextAlign = pBotton_Center 
+0

這個問題已經被接受的答案,你的答案不會添加新的信息 – Guenther