Foxtable(狐表)用户栏目专家坐堂 → [下载][分享]Listbox间距调整函数


  共有4516人关注过本帖平板打印复制链接

主题:[下载][分享]Listbox间距调整函数

帅哥哟,离线,有人找我吗?
jnletao
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:四尾狐 帖子:936 积分:7719 威望:0 精华:0 注册:2013/7/7 13:37:00
[下载][分享]Listbox间距调整函数  发帖心情 Post By:2014/3/8 13:23:00 [只看该作者]

借花献佛,把有点甜老师 的“加大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

 


 回到顶部
总数 11 1 2 下一页