curiousvbnet
Programmer
Hi, i have created a listview called listview1.
When a user cliks on an item he can see in the treeview2
-the parent terms of the item( each item is a different term)
-the name of the microthesaurus to which it belongs( microthesaurus is a semantic field ex : economy, history, geography etc...)
it is possible a term has two parents, in that case i can see in the treeview2 the term and its two parents like this
parent1
the term
microthesaurus1's name
parent2
the term
microthesaurus2' name
i have created a procedure to search the parent term of the selected term , called FindGenericTermes.
I can see the parent term of the selected term.
I have created another sub 'FindMicrothesaurus2' to find the microthesaurus of the term, [blue]but with this sub i can not see in the treeview2 the microthesaurus name [/blue].
Here is the code i use until now
here is the findmicrothesaurus2 code
When a user cliks on an item he can see in the treeview2
-the parent terms of the item( each item is a different term)
-the name of the microthesaurus to which it belongs( microthesaurus is a semantic field ex : economy, history, geography etc...)
it is possible a term has two parents, in that case i can see in the treeview2 the term and its two parents like this
parent1
the term
microthesaurus1's name
parent2
the term
microthesaurus2' name
i have created a procedure to search the parent term of the selected term , called FindGenericTermes.
I can see the parent term of the selected term.
I have created another sub 'FindMicrothesaurus2' to find the microthesaurus of the term, [blue]but with this sub i can not see in the treeview2 the microthesaurus name [/blue].
Here is the code i use until now
Code:
Private Sub ListView1_ItemActivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.ItemActivate
Dim iSelectedTermeID As Integer, strLibTerme As String, id_mt As Integer
'déclaration de deux arrays qui vont contenir plusieurs lignes
Dim drNAs() As DataRow, drSyns() As DataRow, drNA As DataRow, drSYN As DataRow
Dim nNANode As TreeNode, nSynNode As TreeNode
If Not ListView1.FocusedItem Is Nothing AndAlso Not ListView1.FocusedItem.Tag Is Nothing Then
ListView1.FocusedItem.ForeColor = SystemColors.HighlightText.Magenta
iSelectedTermeID = CType(ListView1.FocusedItem.Tag, Integer)
strLibTerme = ListView1.SelectedItems(0).Text
'
Dim matchingnodes As New Collection
we search the node in the treeview1 first
FindNode(iSelectedTermeID, TreeView1.Nodes, matchingnodes)
Dim nbResults As Integer = matchingnodes.Count
For Each nNode1 As TreeNode In matchingnodes
'we search the tag of the current microthesaurus
lib_mt_listitem_activate = GetMicroThesaurusForNode2(nNode1)
MessageBox.Show(lib_mt_listitem_activate)
If Not nNode1 Is Nothing Then
With nNode1
.BackColor = SystemColors.Highlight.DeepSkyBlue
.ForeColor = SystemColors.HighlightText.MediumSlateBlue
End With
nNode1.ExpandAll()
[green] 'we create the node in treeview2 with the selected item in the listview1 [/green]
nNode2 = New TreeNode(strLibTerme)
'TreeView2.Nodes.Add(nNode2)
With nNode2
.BackColor = SystemColors.Highlight.DeepSkyBlue
.ForeColor = SystemColors.HighlightText.MediumSlateBlue
'on affecte l'icone vide au nouveau noeud crée
.ImageIndex = 3
.SelectedImageIndex = 3
' on affecte à chaque terme du treeview2 le tag "GT" + ID_TERME
nNode2.Tag = "GT" & iSelectedTermeID.ToString
End With
[blue]this is the sub which causes problem[/blue]
[red] FindMicrothesaurus2(lib_mt_listitem_activate, nNode2.Clone)[/red]
FindGenericTermes(iSelectedTermeID, nNode2.Clone)
TreeView2.ExpandAll()
TreeView2.SelectedNode = nNode2
Next
End If 'fin de If Not ListView1.FocusedItem Is Nothing AndAlso Not ListView1.FocusedItem.Tag Is Nothing Then
End Sub
Code:
[blue]Private Sub FindMicrothesaurus2(ByVal TermeTag As String, ByRef nNode As TreeNode)[/blue]
Dim drSelected_mt As DataRow()
Dim nNewNode As TreeNode
' TermeTag is the microthesaurus tag of the current node
'we need to find the microthesaurus label and for this we need the microthesaurus ID
Dim MT_ID As Integer
MT_ID = Integer.Parse(TermeTag.Substring(2))
[green] drSelected_mt = objDS.Tables("MICRO_THESAURUS").Select("ID_MICRO_THESAURUS = " + MT_ID.ToString)[/green]
If drSelected_mt.Length > 0 Then
For Each drRow As DataRow In drSelected_mt
nNewNode = New TreeNode("(MT) " & CType(drRow("Lib_MICRO_THESAURUS"), String))
nNewNode.Tag = "MT" & CType(drRow("ID_MICRO_THESAURUS"), Integer).ToString
nNewNode.ForeColor = SystemColors.Highlight.Maroon
we add nNewNode to the nNode(it means nNode2 in our case)
nNode.Nodes.add(nNewNode)
Next
Else
nNewNode = New TreeNode("(this term does not belong to a microthesaurus)")