我有一个函数“listView1_DrawSubItem”的问题。我只更改第二栏,因为我必须在第二栏中放置一些图片。 问题出在FONT上。当我绘制第二列字体比第一列更清晰。只有当我第一次打开图表形式时,它才会出现。 由于它在代码中显示第一列默认是drawinng,第二列是由我绘制的。C#ListView 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;
}
一个问题。当我更新和更改复选框时,它闪烁。我使用Property DoubleBuffered alredy: “PropertyInfo property1 = typeof(TreeView).GetProperty(”DoubleBuffered“,BindingFlags.NonPublic | BindingFlags.Instance); property1.SetValue(treeView1,true,null);” – user3447900 2014-10-14 07:13:23
好的我发现它在 [TreeView闪烁](http://stackoverflow.com/questions/10362988/treeview-flickering) – user3447900 2014-10-14 07:51:57