以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  如何对齐字符  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=95854)

--  作者:blackzhu
--  发布时间:2017/2/7 9:42:00
--  如何对齐字符
我动态生成按钮,但是由于按钮的标题的长度不一样,我如何来对齐:

比如  按钮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


应该怎么改比较好?

--  作者:有点色
--  发布时间:2017/2/7 9:45:00
--  

文本位置,设置成 MiddleLeft

 

然后,左边加入空格即可。


--  作者:blackzhu
--  发布时间:2017/2/7 10:01:00
--  
我试试