''修改ItemHeight无效
Private Sub ListBox1_DrawItem(sender As Object, e As DrawItemEventArgs) Handles ListBox1.DrawItem e.DrawBackground() e.DrawFocusRectangle() '' 让文字位于Item的中间 '' 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) '' e.Graphics.DrawString(listBox1.Items(e.Index).ToString(), e.Font, New SolidBrush(e.ForeColor), rf) e.Graphics.DrawString(ListBox1.Items(e.Index).ToString(), e.Font, New SolidBrush(Color.Black), e.Bounds) End Sub Private Sub ListBox1_MeasureItem(sender As Object, e As MeasureItemEventArgs) Handles ListBox1.MeasureItem e.ItemHeight = 18 '' If (e.Index = 2) ''只设置第三项的高度 '' e.ItemHeight = 50 '' End If End Sub
来源:https://www.cnblogs.com/rf8862/p/12578976.html