Jump to content

check na treeview e adiciona na listview


Anamotiris
 Share

Recommended Posts

Gostava de quando faço check na treeview a um node adicionar o nome da node a uma listbox...

caso retire o check entao remova essa node da list.

ou seja as duas estarem relacionadas atraves de um evento treeview1_AfterCheck. Penso que seja esse o principio

Toda a ajuda é bem vinda 👍

obrigado.

Link to comment
Share on other sites

Olá,

Experimenta assim:

   

Private Sub TreeView1_AfterCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterCheck
        If e.Node.Checked Then
            ListBox1.Items.Add(e.Node.Text)
        Else
            ListBox1.Items.Remove(e.Node.Text)
        End If
    End Sub
Link to comment
Share on other sites

Espera é uma listview e não uma listbox ...

   

Private Sub TreeView1_AfterCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterCheck
        If e.Node.Checked Then
            ListView1.Items.Add(e.Node.Text)
        Else
            ListView1.FindItemWithText(e.Node.Text).Remove()
        End If
    End Sub
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.