Home All Groups Group Topic Archive Search About

Comment renommer une Node d'un TreeView en VB2005 ?

Author
27 Jun 2006 10:27 PM
claude
Bonjour je cherche à renommer une node d'un TreeView mais ça ne fonctionne pas.
Malgré un Nodes.Find qui me retourne bien le Node en cours avant changement de son nom,
et qui grace à cela je récupère aussi l'index.
Ci-joint code non fonctionnel

Merci.


If MessageBox.Show("Etes-vous certain de vouloir Renommer ce répertoire [" & strVal & "] ?", "Renommer répertoire", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = DialogResult.OK Then
                    Dim TreeRen() As TreeNode = Me.DirTreeView.Nodes.Find(strVal, True)
                    For i As Integer = 0 To UBound(TreeRen)
                        If TreeRen(i).IsVisible Then
                            Dim indexNode As Integer = TreeRen(i).Index  ' Retourne bien l'index correspondant

                            Dim frmModif As New frm_Saisie
                            frmModif.tb_ValName.Enabled = False
                            frmModif.tb_ValName.Text = Strings.Mid(strVal, strVal.LastIndexOf("\") + 2)
                            frmModif.tb_Val.Text = Strings.Mid(strVal, strVal.LastIndexOf("\") + 2)
                            frmModif.ShowDialog()
                            '*** 1er Essai ne fonctionne pas non plus Element inexistant ?
                            Me.DirTreeView.Nodes.Item(indexNode).Text = frmModif.tb_Val.Text
                            Me.DirTreeView.Nodes.Item(indexNode).Name = Strings.Left(strVal, strVal.LastIndexOf("\") + 1) & frmModif.tb_Val.Text
                            '*** Autre Essai ne fonctionne pas non plus Element inexistant ?
                            'TreeRen(i).Text = frmModif.tb_Val.Text
                            'TreeRen(i).Name = Strings.Left(strVal, strVal.LastIndexOf("\") + 1) & frmModif.tb_Val.Text
                            'Me.DirTreeView.Nodes.RemoveAt(indexNode)
                            'Me.DirTreeView.Nodes.Insert(indexNode, TreeRen(i))

                            lvw_Reg.Items.Item(ilv).Text = frmModif.tb_Val.Text
                            lvw_Reg.Items.Item(ilv).SubItems(1).Text = Strings.Left(strVal, strVal.LastIndexOf("\") + 1) & frmModif.tb_Val.Text
                            IO.Directory.Move(strVal, Strings.Left(strVal, strVal.LastIndexOf("\") + 1) & frmModif.tb_Val.Text)
                            frmModif.Dispose()
                        End If
                    Next
                End If


--------------=  Posted using GrabIt  =----------------
------=  Binary Usenet downloading made easy =---------
-=  Get GrabIt for free from http://www.shemes.com/  =-

Author
28 Jun 2006 4:58 AM
Cor Ligthert [MVP]
Claude,

This is a English language newsgroup, most visitors are from countries all
over the world, from which for a major part English is not their first
language. However we are used to do the conversation in English.

There is a newsgroup special for French  to, it has a much simpler name

microsoft.public.dotnet.vb

As an advice, try to make a litle sample instead of a copied part of your
program with even outcommented code in it. That makes it easier to help you.

By instance replace all string variables as much as possible by hard
strings. Probably the chance that you than find the problem yourself is very
high..

I hope this helps something

Cor

Show quoteHide quote
"claude" <Noclaude***@gmail.com> schreef in bericht
news:1151447221.20315.0@proxy02.news.clara.net...
> Bonjour je cherche à renommer une node d'un TreeView mais ça ne fonctionne
> pas.
> Malgré un Nodes.Find qui me retourne bien le Node en cours avant
> changement de son nom,
> et qui grace à cela je récupère aussi l'index.
> Ci-joint code non fonctionnel
>
> Merci.
>
>
> If MessageBox.Show("Etes-vous certain de vouloir Renommer ce répertoire ["
> & strVal & "] ?", "Renommer répertoire", MessageBoxButtons.OKCancel,
> MessageBoxIcon.Warning) = DialogResult.OK Then
>                    Dim TreeRen() As TreeNode =
> Me.DirTreeView.Nodes.Find(strVal, True)
>                    For i As Integer = 0 To UBound(TreeRen)
>                        If TreeRen(i).IsVisible Then
>                            Dim indexNode As Integer = TreeRen(i).Index  '
> Retourne bien l'index correspondant
>
>                            Dim frmModif As New frm_Saisie
>                            frmModif.tb_ValName.Enabled = False
>                            frmModif.tb_ValName.Text = Strings.Mid(strVal,
> strVal.LastIndexOf("\") + 2)
>                            frmModif.tb_Val.Text = Strings.Mid(strVal,
> strVal.LastIndexOf("\") + 2)
>                            frmModif.ShowDialog()
>                            '*** 1er Essai ne fonctionne pas non plus
> Element inexistant ?
>                            Me.DirTreeView.Nodes.Item(indexNode).Text =
> frmModif.tb_Val.Text
>                            Me.DirTreeView.Nodes.Item(indexNode).Name =
> Strings.Left(strVal, strVal.LastIndexOf("\") + 1) & frmModif.tb_Val.Text
>                            '*** Autre Essai ne fonctionne pas non plus
> Element inexistant ?
>                            'TreeRen(i).Text = frmModif.tb_Val.Text
>                            'TreeRen(i).Name = Strings.Left(strVal,
> strVal.LastIndexOf("\") + 1) & frmModif.tb_Val.Text
>                            'Me.DirTreeView.Nodes.RemoveAt(indexNode)
>                            'Me.DirTreeView.Nodes.Insert(indexNode,
> TreeRen(i))
>
>                            lvw_Reg.Items.Item(ilv).Text =
> frmModif.tb_Val.Text
>                            lvw_Reg.Items.Item(ilv).SubItems(1).Text =
> Strings.Left(strVal, strVal.LastIndexOf("\") + 1) & frmModif.tb_Val.Text
>                            IO.Directory.Move(strVal, Strings.Left(strVal,
> strVal.LastIndexOf("\") + 1) & frmModif.tb_Val.Text)
>                            frmModif.Dispose()
>                        End If
>                    Next
>                End If
>
>
> --------------=  Posted using GrabIt  =----------------
> ------=  Binary Usenet downloading made easy =---------
> -=  Get GrabIt for free from http://www.shemes.com/  =-
>