|
とりあえず、要求を満たすという意味で。 Activation プロパティを「OneClick」に設定。ItemActivate イベントを利用。
#アイコンが「手」に変わるのと↓がVBなのはご愛嬌。
Private _CurrentItemIndex As Integer = -1
Private Sub ListView1_ItemActivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.ItemActivate
If Not ListView1.SelectedItems.Count > 0 Then Exit Sub End If
Dim selectedIndex As Integer = ListView1.SelectedItems(0).Index
If _CurrentItemIndex < 0 Then _CurrentItemIndex = selectedIndex Exit Sub End If
If selectedIndex <> _CurrentItemIndex Then Dim msg As String = "行を変更しますか?" Dim result As DialogResult = MessageBox.Show(msg, Me.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) If result <> Windows.Forms.DialogResult.Yes Then With ListView1.Items(_CurrentItemIndex) .Selected = True .Focused = True .EnsureVisible() End With Else _CurrentItemIndex = selectedIndex End If End If
End Sub
|