Bonjour,

j'ai un petit soucis pour éditer un subitem quand il y est vide dans listview1. mon code fonction quand edite un subitem pour modifier une valeurs.

voici mon code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Private Sub EditerToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim sp As New Point(MousePosition.X - Me.PointToScreen(ListView1.Location).X, MousePosition.Y - Me.PointToScreen(ListView1.Location).Y)
        hitinfo = ListView1.HitTest(sp)
        If Not hitinfo.SubItem Is Nothing Then
            editorTextbox.Bounds = hitinfo.SubItem.Bounds
            editorTextbox.Text = hitinfo.SubItem.Text
            editorTextbox.Select()
            editorTextbox.Show()
            editorTextbox.Visible = True
            editorTextbox.ReadOnly = False
            AddHandler editorTextbox.Leave, AddressOf editorTextbox_LostFocus
        End If
    End Sub
Private Sub editorTextbox_LostFocus(ByVal sender As Object, ByVal e As EventArgs)
        hitinfo.SubItem.Text = editorTextbox.Text
        editorTextbox.Hide()
        AddHandler editorTextbox.Validating, AddressOf editorTextbox_Validating
    End Sub
 
    Private Sub editorTextbox_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs)
        ListView1.Update()
    End Sub
je voudrais savoir comment faire pour éditer un subitem vide ou pas? Merci pour votre réponse.