zoukankan      html  css  js  c++  java
  • 修改ListBox行高

    ''修改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
  • 相关阅读:
    HTML学习基础(一)
    初识C#
    SQL小知识
    jQuery(四)
    jQuery(三)
    认识jQuery(二)
    认识Jquery
    初识Javascript
    初识HTML
    博客,你好!
  • 原文地址:https://www.cnblogs.com/rf8862/p/12578976.html
Copyright © 2011-2022 走看看