vb6.0的combobox里面的文字如何居中显示,求救
vb6.0的combobox里面的文字如何居中显示,求救
Option Explicit
Private Sub Form_Load()
Dim i As Long, W1 As Long, W2 As Long, W3 As Long, S As String, arr() As String
Me.ScaleMode = 3
Combo1.AddItem "C"
Combo1.AddItem "CS"
Combo1.AddItem "CSD"
Combo1.AddItem "CSDN中文网站"
Me.Font.Size = 48
Me.FontName = "黑体"
Combo1.Font.Size = Me.Font.Size
Combo1.FontName = Me.FontName
W2 = Me.TextWidth(" ")
W3 = Combo1.Width '/ Screen.TwipsPerPixelX
ReDim arr(Combo1.ListCount - 1)
For i = 0 To Combo1.ListCount - 1
S = Combo1.List(i)
S = Trim(S)
W1 = Me.TextWidth(S)
arr(i) = Space(((W3 - W1) / 2) / W2) & S
Next
Combo1.Clear
For i = 0 To UBound(arr)
Combo1.AddItem arr(i)
Next
Combo1.ListIndex = Combo1.ListCount - 1
End Sub