且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何设置动态添加标签的文本对齐方式

更新时间:2023-12-04 23:51:28

您需要将控件转换为标签:

You need to cast the control to a label:
For Each c As Control In Panel1.Controls
    stringVariable = c.name
    Dim l As Label = TryCast(c, Label)
    If l IsNot Nothing Then
        l.TextAlign = ContentAlignment.MiddleCenter
    End If
Next