如何设置动态添加标签的文本对齐方式 我在字符串变量中获取标签名称 在面板中动态添加一个标签
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
请帮助
答案 0 :(得分:2)
DirectCast(Me.Panel1.Controls("Label1"), Label).TextAlign = ContentAlignment.TopRight
答案 1 :(得分:0)
我发现这些值会设置TextAlign
Public pTop_Center As Long = 2
Public pMiddle_Center As Long = 32
Public pBotton_Center = 512
btn.TextAlign = pBotton_Center