private void listboxbatch_DrawItem(object sender, DrawItemEventArgs e)
{
e.DrawBackground();
e.DrawFocusRectangle();
//让文字位于Item的中间
float difH = (e.Bounds.Height - e.Font.Height) / 2;
RectangleF rf = new RectangleF(e.Bounds.X, e.Bounds.Y + difH, e.Bounds.Width, e.Font.Height);
e.Graphics.DrawString(listboxbatch.Items[e.Index].ToString(), e.Font, new SolidBrush(e.ForeColor), rf);
}
转载于:https://www.cnblogs.com/glyson/archive/2012/03/12/2392219.html