修改WinForm ListBox的项目高度
WinForm中默认的ListBox控件项目高度比较低,如果需要增加高度可使用以下办法。
先看两张截图:
- 默认ListBox

- 增加高度后

方法如下:
- 修改ListBox控件的DrawMode属性为OwnerDrawFixed
- 修改ListBox控件的ItemHeight属性为你需要的高度
- 添加ListBox的DrawItem事件
private void listBox1_DrawItem(object sender, DrawItemEventArgs e)
{
e.DrawBackground();
e.DrawFocusRectangle();
var font = new Font(e.Font.Name, 12);
e.Graphics.DrawString(listBox1.Items[e.Index].ToString(), font, new SolidBrush(Color.Black), e.Bounds);
}
Categories
Tags
Jekyll(3)
Windows(1)
GitHub(4)
vs(4)
Portable(1)
hompage(1)
sitemap(1)
ruby(1)
gem(1)
qrcode(1)
jquery(1)
responsive(1)
Linux(6)
crontab(1)
sqlserver(4)
split(1)
backup(1)
js(1)
version(1)
csharp(2)
office(1)
com(1)
iis(1)
win8(1)
drag(1)
remote desktop(1)
Git GUI(1)
mail(1)
HTML(1)
table(1)
service(1)
32bit(1)
python(5)
pylesson(4)
volatile(1)
multithreading(1)
singleton(1)
webapi(2)
actionfilter(3)
filterprovider(1)