ListBox的ItemHeight问题

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);
        }

posted on 2012-03-12 18:10  Glyson  阅读(529)  评论(0编辑  收藏  举报