正如LarsTech他在评论中所建议的那样,所有其他评论都会导致某种完全编码的例子,这可能会让你感到困惑.我用几行代码制作了这个演示程序,供您遵循并轻松入门:
listBox1.DrawMode = DrawMode.OwnerDrawVariable;
//First add some items to your listBox1.Items
//MeasureItem event handler for your ListBox
private void listBox1_MeasureItem(object sender, MeasureItemEventArgs e)
{
if (e.Index == 2) e.ItemHeight = 50;//Set the Height of the item at index 2 to 50
}
//DrawItem event handler for your ListBox
private void listBox1_DrawItem(object sender, DrawItemEventArgs e)
{
e.DrawBackground();
e.Graphics.DrawString(listBox1.Items[e.Index].ToString(), e.Font, new SolidBrush(e.ForeColor), e.Bounds);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13074 次 |
| 最近记录: |