我动态生成按钮,但是由于按钮的标题的长度不一样,我如何来对齐:
比如 按钮1: AA
按钮2: AAA
按钮3: AAAA
我要的效果是:
按钮1: AA
按钮2: AAA
按钮3: AAAA
我代码这样写,但是不起作用:
Dim Customers As List(Of String())
Customers=DataTables("表A").GetValues("第二列|第三列","第四列='" & g & "'","第一列") '这个G是另外的变量
For Each c() As String In customers
pt =e.form.CreateControl("custom_" & c(0), ControlTypeEnum.button)
' Dim s As String = "? " & c(1)
Dim str As String = c(1)
Dim s As String
If str.Length <= 6 Then
s = left(str,6).Padright(6," ")
Else
s =s
End If
pt.Text = s
pt.height=30
pt.Width =lbpanel.Width
pt.FlatStyle = FlatStyle.flat
pt.BackColor = Color.Transparent
pt.BorderSize = 0
pt.TextAlign = ContentAlignment.MiddleCenter
pt.Font = New Font("微软雅黑",9)
pt.Dock = Windows.Forms.DockStyle.top
pl.AddControl(pt)
next
应该怎么改比较好?