C# と VB.NET の質問掲示板

わんくま同盟

ASP.NET、C++/CLI、Java 何でもどうぞ

C# と VB.NET の入門サイト


(過去ログ 151 を表示中)
■87696 / )  DataGridViewの複数行の選択
□投稿者/ 太麺 (1回)-(2018/06/20(Wed) 18:23:19)

分類:[.NET 全般] 

開発環境:Windows7 32bit Visual Studio2010 .NET Frame work4.7

お世話になっております。
DataGridViewでCtrlキーを押さなくてもクリックだけでセルを複数行選択できるようにコードを書いたのですが

Private Sub DataGridView1_CellMouseUp(ByVal sender As Object, ByVal e As DataGridViewCellMouseEventArgs) Handles DataGridView2.CellMouseUp

    Dim selectedCells As DataGridViewSelectedCellCollection = DataGridView2.SelectedCells

    For Each cell As DataGridViewCell In selectedCells

        If cellCollection.Contains(cell) Then
            cellCollection.Remove(cell)
            cell.Selected = False
        Else
            cellCollection.Add(cell)
        End If
    Next

    For Each cell As DataGridViewCell In cellCollection
        cell.Selected = True
    Next

End Sub

やりたいこと自体は出来ているのですがセルをクリックするたびに既に選択状態のセルがちらつきます。
ちらつかないようにする方法はありますか?ダブルバッファリングを有効にしてみましたがうまくいきませんでした。
SelectionModeプロパティはFullRowSelect、MultiSelecプロパティtはTrueになっています。

返信 編集キー/


管理者用

- Child Tree -