By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,369 Members | 1,147 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,369 IT Pros & Developers. It's quick & easy.

Comment renommer une Node d'un TreeView en VB2005 ?

P: n/a
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/ =-

Jun 27 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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

"claude" <No*********@gmail.com> schreef in bericht
news:11****************@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/ =-

Jun 28 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.