2

PaintParts は、デフォルトでどの部分をペイントする必要があるかを示していると思いました。正常に動作しているように見えますが、DataGridViewCell を選択すると、すべてがデフォルトで描画されます。コンテンツ以外のすべてをペイントしたいだけです。ここに私のコードがあります:

private void dataGridView_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e){
   e.PaintParts = DataGridViewPaintParts.All & ~DataGridViewPaintParts.ContentForeground;
}

セルが選択されていない場合は問題なく動作しますが、セルを選択すると、デフォルトですべての背景とコンテンツが描画されます。デフォルト/標準DataGridViewで問題ありませんが、カスタム/サードパーティを扱っていDataGridViewます。

それが何であるかを説明し、その解決策を教えてください。

どうもありがとう!

4

2 に答える 2

1

コンテンツの前景を除くすべてをこの方法で描画するように指定するだけでよいと思います。

私はこれを行いましたが、動作します。

すべての paintParts がペイントされていない特定のセルのみが必要な場合を除き、これはまさに必要なものです。

private void dataGridView_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
{
    e.PaintCells(e.ClipBounds, DataGridViewPaintParts.ContentBackground | DataGridViewPaintParts.Border | DataGridViewPaintParts.Background | DataGridViewPaintParts.SelectionBackground);
    e.Handled = true;

    //The e.Handled = true tells the event handler that the event has been completed and that the system doesn't need to do anymore processing.  This line is required to ensure it doesn't process any further(paint more stuff).
}

ps。ちょうどこれを見つけた

C# DataGridViewCheckBoxColumn 非表示/グレーアウト

于 2013-05-30T18:58:20.647 に答える
0

DataGridViewX の場合、Office 2007 拡張機能をオフにする必要があります

試す

this.nameofyoudatagridview.PaintEnhancedSelection = false;

プロパティを設定するとき

これはうまくいきましたか?

于 2013-07-30T01:38:59.377 に答える