借花献佛,把有点甜老师 的“加大ListBox间隔的例子” 做成了 函数。有需要的朋友可以用下。
窗口与控件事件
窗口1_AfterLoad
Functions.Execute("ListBoxDraw","窗口1")
自定义函数
ListBoxDraw
'Args(0) 窗体名
For Each c As WinForm.Control In Forms(Args(0)).Controls
If Typeof c Is
WinForm.ListBox Then '判断控件
Dim cbx As
System.Windows.Forms.ListBox = Forms(Args(0)).Controls(c.name).BaseControl
cbx.DrawMode
= System.Windows.Forms.DrawMode.OwnerDrawFixed
cbx.ItemHeight
= 20
AddHandler
cbx.DrawItem, AddressOf BoxList_DrawItem
End If
Next
全局代码
Public Sub BoxList_DrawItem(sender As object, e As
System.Windows.Forms.DrawItemEventArgs)
'重绘列表控件行间距
If e.Index <
0 Then Return
e.DrawBackground()
e.DrawFocusRectangle()
e.Graphics.DrawString(sender.Items(e.Index).ToString(), e.Font, new
SolidBrush(e.ForeColor), e.Bounds.X, e.Bounds.Y + 3)
End Sub