''修改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

 

相关文章:

  • 2022-12-23
  • 2021-11-14
  • 2021-05-29
  • 2021-10-17
  • 2021-06-05
  • 2022-12-23
猜你喜欢
  • 2021-10-05
  • 2022-12-23
  • 2021-08-18
  • 1970-01-01
  • 2021-09-19
  • 2022-01-06
  • 2022-01-05
相关资源
相似解决方案