【发布时间】:2014-10-12 11:34:46
【问题描述】:
我对函数“listView1_DrawSubItem”有疑问。我只更改第二列,因为我必须在第二列中放置一些图像。 问题出在字体上。当我画第二列时,字体比第一列更清晰。令人惊奇的是,它仅在我第一次打开图表表单时才出现。 如代码所示,第一列默认绘制,第二列由我绘制。
有这样的图像。以全分辨率观看。
这是我的代码:
fo 是我可以更改的字体。
private void listView1_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
if (e.Header != this.columnHeader2)
{
e.DrawDefault = true;
return;
}
if (e.Item.SubItems[1].Text == "1")
{
e.DrawBackground();
e.Graphics.DrawImage(Properties.Resources.Blank_Badge_Green, e.SubItem.Bounds.Location.X, e.SubItem.Bounds.Location.Y, 10, 10);
}
else if (e.Item.SubItems[1].Text == "0")
{
e.DrawBackground();
e.Graphics.DrawImage(Properties.Resources.Blank_Badge_Grey, e.SubItem.Bounds.Location.X, e.SubItem.Bounds.Location.Y, 10, 10);
}
else
{
e.DrawBackground();
e.Graphics.DrawString(e.SubItem.Text, fo, new SolidBrush(e.SubItem.ForeColor), e.SubItem.Bounds.Location.X, e.SubItem.Bounds.Location.Y);
}
}
private void listView1_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
{
e.DrawDefault = true;
}
【问题讨论】: