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

请帮忙

4

2 回答 2

2
DirectCast(Me.Panel1.Controls("Label1"), Label).TextAlign = ContentAlignment.TopRight
于 2012-12-01T10:16:06.260 回答
0

我发现这些值会设置 TextAlign

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

 btn.TextAlign = pBotton_Center
于 2017-08-10T16:27:42.457 回答