我有一個函數「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