MouseHoverが発生したときにCheckBoxが境界線を表示するカスタムDataGridViewを作成しています。C#winformで描画するのがかなり遅い
ここまでは私がこれまで行ってきたことです。
void checkBox_MouseLeave(object sender, EventArgs e)
{
//showBorder defines whether the border is drawn.
this.showBorder = false;
this.DataGridView.InvalidateCell(this);
}
void CheckBoxMouseHover(object sender, EventArgs e)
{
this.showBorder = true;
this.CheckBox.BringToFront();
this.DataGridView.InvalidateCell(this);
}
protected override void Paint(...........)
{
..........
if (showBorder)
{
GraphicsPath border=new GraphicsPath();
border.AddRectangle(new Rectangle(checkBoxPosition.X-1,checkBoxPosition.Y-1,checkBoxSize.Width+1,checkBoxSize.Height+1));
graphics.DrawPath(new Pen(borderColor,1),border);
}
}
しかし、私はボーダーショーを見るのに約0.5秒間待たなければならないほど遅いです。とにかく、MouseLeaveは正常に動作します。 ここでどのようにパフォーマンスを改善できますか?
さらに、チェックボックスをカスタマイズするにはどうすればよいですか?背景色などを入力します。
あなたはDouble Bufferingに慣れていますか? http://www.bobpowell.net/doublebuffer.htm –
私は自動ダブルバッファリングを試みましたが、違いはありませんでした。 – user840866