Comment Renommer une Node d'un TreeView en VB2005 ?
1 réponse
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/ =-
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Claude
En cherchant un peut dans toute les manières possibles j'ai trouvé et ca fonctionne. Je renomme un Node alors que celui-ci n'est pas sélectionné mais son parent.
If MessageBox.Show("Etes-vous certain de vouloir Renommer ce répertoire [" & strVal & "] ?", "Renommer répertoire", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = DialogResult.OK Then
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()
For Each oldNode As TreeNode In Me.DirTreeView.SelectedNode.Nodes If oldNode.Name = strVal Then oldNode.Name = Strings.Left(strVal, strVal.LastIndexOf("") + 1) & frmModif.tb_Val.Text oldNode.Text = frmModif.tb_Val.Text Exit For End If Next
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/ =-
En cherchant un peut dans toute les manières possibles j'ai trouvé et ca
fonctionne.
Je renomme un Node alors que celui-ci n'est pas sélectionné mais son parent.
If MessageBox.Show("Etes-vous certain de vouloir Renommer ce répertoire [" &
strVal & "] ?", "Renommer répertoire", MessageBoxButtons.OKCancel,
MessageBoxIcon.Warning) = DialogResult.OK Then
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()
For Each oldNode As TreeNode In Me.DirTreeView.SelectedNode.Nodes
If oldNode.Name = strVal Then
oldNode.Name = Strings.Left(strVal, strVal.LastIndexOf("") + 1) &
frmModif.tb_Val.Text
oldNode.Text = frmModif.tb_Val.Text
Exit For
End If
Next
"claude" <Noclaudetom@gmail.com> a écrit dans le message de news:
1151447167.20309.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/ =-
En cherchant un peut dans toute les manières possibles j'ai trouvé et ca fonctionne. Je renomme un Node alors que celui-ci n'est pas sélectionné mais son parent.
If MessageBox.Show("Etes-vous certain de vouloir Renommer ce répertoire [" & strVal & "] ?", "Renommer répertoire", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = DialogResult.OK Then
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()
For Each oldNode As TreeNode In Me.DirTreeView.SelectedNode.Nodes If oldNode.Name = strVal Then oldNode.Name = Strings.Left(strVal, strVal.LastIndexOf("") + 1) & frmModif.tb_Val.Text oldNode.Text = frmModif.tb_Val.Text Exit For End If Next
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/ =-