篇首语:盛年不重来,一日难再晨。及时宜自勉,岁月不待人。本文由小编为大家整理,主要介绍了知识大全 C# 实现ListBox的Item自定义高度相关的知识,希望对你有一定的参考价值。
C# 实现ListBox的Item自定义高度 以下文字资料是由(全榜网网)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!
最 Winform太久没碰以至于连ListBox的item自定义高度都忘了如何做结果在msdn查了不少时间 堆代码虽然是件很无聊的事 但不可否认即使是项数量工式的枯燥工作也令现在的我有点力不从心 代码 先设置ListBox的DrawMode=OwnerDrawVariable也就是自己来画ListItem 接着就可以实现Listbox的两个事件 分别如下 ? private void listBox _DrawItem(object sender DrawItemEventArgs e) e DrawBackground(); e DrawFocusRectangle(); e Graphics DrawString(listBox Items[e Index] ToString() e Font new SolidBrush(Color Red) e Bounds); private void listBox _MeasureItem(object sender MeasureItemEventArgs e) if (e Index == ) e ItemHeight = ; lishixinzhi/Article/program/net/201311/11421