C#中listBox修改每项的高度

1、找到listbox的属性修改“DrawMode”为“OwerDrawVariable”;修改“ItemHeight”的值为你要设置的每列的高度,图中设置为“20”


2、点击“事件”找到“DrawItem”双击进入cs文件的代码块,编写代码设置每列的属性:

private void lb_log_DrawItem(object sender, DrawItemEventArgs e)
        {
            e.DrawBackground();
            e.DrawFocusRectangle();
            e.Graphics.DrawString(lb_log.Items[e.Index].ToString(), e.Font, new SolidBrush(Color.Black), e.Bounds);
        }

猜你喜欢

转载自blog.csdn.net/qq_31967985/article/details/80078850