.NETのDataGridView上で右クリックを行った場合、左クリックの時のような選択状態にならない・・・。
これの対応は、CellMouseClickイベントで行う。以下VBでの例
Private Sub dgvData_CellMouseClick(sender As System.Object, e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles dgvData.CellMouseClick
|
選択状態を作り出すだけなら上記のCellMouseClickイベントで良いけど、ここで同時にContextMenuStripの表示を行いたい場合は、
CellMouseClickイベントではなく、CellContextMenuStripNeededイベントを使用する。
Private Sub dgvData_CellContextMenuStripNeeded(sender As System.Object, e As System.Windows.Forms.DataGridViewCellContextMenuStripNeededEventArgs) Handles dgvData.CellContextMenuStripNeeded
|
後は、それぞれ必要な処理を入れておけばいい。