2012-12-01 3 views
0

이벤트 ::동적으로 추가 라벨의 텍스트 정렬을 설정하는 방법을 내가 변수 하나의 레이블은 동적으로 폼로드에 패널</p> <pre><code>Dim instance As New Label Dim stringVariable As String </code></pre> <p>에 추가 된 문자열에서 라벨의 이름을 얻고 동적으로 추가 라벨 의 텍스트 정렬을 설정하는 방법

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 

하지만 가능하지

답변

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

감사합니다 매우 – Dandy

0

도와주세요

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

에 나는이 값을 설정 textAlign을

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

btn.TextAlign = pBotton_Center 
+0

이 문제가 이미 허용 대답 할 것이다 것을 발견하여 대답은 새로운 정보를 추가하지 않는다. – Guenther