listBox 行高设置方法
属性 DrawMode=OwnerDrawVariable
itemHeight=20 '这是设置的行高
在listBox的DrawItem事件中加入代码:
Try
e.DrawBackground()
''''e.DrawFocusRectangle()
'下面代码使文本上下居中
Dim difH As Single = (e.Bounds.Height - e.Font.Height) / 2
Dim rf As RectangleF = New RectangleF(e.Bounds.X, e.Bounds.Y + difH, e.Bounds.Width, e.Font.Height)
Dim txt As String = ListBox1.GetItemText(ListBox1.Items(e.Index))
vba listbox控件详解
e.Graphics.DrawString(txt, e.Font, New SolidBrush(e.ForeColor), rf)
Catch ex As Exception
End Try

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。