Home Page
Articoli
Tips & Tricks
News
Forum
Archivio Forum
Blogs
Sondaggi
Rss
Video
Utenti
Chi Siamo
Contattaci
Username:
Password:
Login
Registrati ora!
Recupera Password
Home Page
Stanze Forum
App. WinForms / WPF .NET
DUBBIO SU TREEVIEW
giovedì 11 gennaio 2007 - 00.05
Elenco Threads
Stanze Forum
Aggiungi ai Preferiti
Cerca nel forum
MATTEHGT
Profilo
| Junior Member
83
messaggi | Data Invio:
gio 11 gen 2007 - 00:05
Ho la seguente problematica: ho la necessità di eliminare lo stato di checked=true ad un nodo figlio selezionato dopo averne selezionato un altro, in sostanza se seleziono un nodo automaticamente si deseleziona quello precedentemente selezionato.
Ho provato con il seguente codice
if e.node.index >0 then
e.node.prevnode.checked=false
Il programma funziona perdelezionando i nodi precedentii a quello selezionato. Il problema è per quelli successivi.
Il codeice sarebbe if e.node.index <(index)
e.node.nextnode.checked=false
Il problema è che non riesco a mettere insieme queste due routine e a far funzionare le due casistiche insieme.
Qualcuno sa darmi un suggerimento?
Grazie
Saluti
maurosegato
Profilo
| Newbie
31
messaggi | Data Invio:
gio 11 gen 2007 - 09:36
Questo ti drovrebbe funzionare..
Private Sub TreeView1_AfterSelect(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
e.Node.Checked = true
SetTreeNodeCheck(directcast(sender, TreeView).Nodes, e.Node, false)
End Sub
public sub SetTreeNodeCheck(byval nodes as TreeNodeCollection, byval escludeTreeNode as TreeNode, byval state as boolean)
for each n as TreeNode in nodes
SetTreeNodeCheck(n.Nodes, escludeTreeNode, state)
if not n.Equals(escludeTreeNode) andalso not n.Checked = state
n.Checked = state
end if
next
end sub
Mauro Segato
MATTEHGT
Profilo
| Junior Member
83
messaggi | Data Invio:
gio 11 gen 2007 - 12:48
L'HO IMPOSTATA COSI'
Private Sub TreeView1_AfterCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterCheck
SetTreeNodeCheck(DirectCast(sender, TreeView).Nodes, e.Node, False)
End Sub
Public Sub SetTreeNodeCheck(ByVal nodes As TreeNodeCollection, ByVal escludeTreeNode As TreeNode, ByVal state As Boolean)
For Each n As TreeNode In nodes
SetTreeNodeCheck(n.Nodes, escludeTreeNode, state)
If Not n.Equals(escludeTreeNode) AndAlso Not n.Checked = state Then
n.Checked = state
End If
Next
End sub
Il nuovo nodo su cui metto il check mi esclude il precedente, ma per selezionare il corrente devo fare un altro clic. E' possibile con un solo clic deselezionare il precedente a attivare il corrente?
Grazie
Saluti
Matteo Agrizzi
maurosegato
Profilo
| Newbie
31
messaggi | Data Invio:
gio 11 gen 2007 - 13:42
prova così:
Private Sub TreeView1_AfterCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterCheck
static last_node_selected as treenode = nothing
if not last_node_selected is nothing then _
last_node_selected.Checked = false
e.Node.Checked = true
last_node_selected = e.Node
End Sub
questo è anche più veloce nell'esecuzione!!!
ciao
Mauro Segato
MATTEHGT
Profilo
| Junior Member
83
messaggi | Data Invio:
gio 11 gen 2007 - 16:32
HO OTTENUTO L'ERRORE ASSICURARSI CHE NON SI TRATTI DI UN CICLO INFINITO O DI UNA RICORSIONE INFINITA
Torna su
Stanze Forum
Elenco Threads
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?
Dopo esserti registrato potrai chiedere
aiuto sul nostro
Forum
oppure aiutare gli altri
Consulta le
Stanze
disponibili.
Registrati ora !