Fetstil Fetstil Kursiv Understrykning linje färgläggning tabellverk Punktlista Nummerlista Vänster Centrerat högerställt Utfyllt Länk Bild htmlmode
  • Forum & Blog
    • Forum - översikt
      • .Net
        • asp.net generellt
        • c#
        • vb.net
        • f#
        • silverlight
        • microsoft surface
        • visual studio .net
      • databaser
        • sql-server
        • databaser
        • access
        • mysql
      • mjukvara klient
        • datorer och komponenter
        • nätverk, lan/wan
        • operativsystem
        • programvaror
        • säkerhet, inställningar
        • windows server
        • allmänt
        • crystal reports
        • exchange/outlook
        • microsoft office
      • mjukvara server
        • active directory
        • biztalk
        • exchange
        • linux
        • sharepoint
        • webbservers
        • sql server
      • appar (win/mobil)
      • programspråk
        • c++
        • delphi
        • java
        • quick basic
        • visual basic
      • scripting
        • asp 3.0
        • flash actionscript
        • html css
        • javascript
        • php
        • regular expresssion
        • xml
      • spel och grafik
        • DirectX
        • Spel och grafik
      • ledning
        • Arkitektur
        • Systemutveckling
        • krav och test
        • projektledning
        • ledningsfrågor
      • vb-sektioner
        • activeX
        • windows api
        • elektronik
        • internet
        • komponenter
        • nätverk
        • operativsystem
      • övriga forum
        • arbete karriär
        • erbjuda uppdrag och tjänster
        • juridiska frågor
        • köp och sälj
        • matematik och fysik
        • intern information
        • skrivklåda
        • webb-operatörer
    • Posta inlägg i forumet
    • Chatta med andra
  • Konto
    • Medlemssida
    • Byta lösenord
    • Bli bonsumedlem
    • iMail
  • Material
    • Tips & tricks
    • Artiklar
    • Programarkiv
  • JOBB
  • Student
    • Studentlicenser
  • KONTAKT
    • Om pellesoft
    • Grundare
    • Kontakta oss
    • Annonsering
    • Partners
    • Felanmälan
  • Logga in

Hem / Tips & tricks

#227 - Gör en total kopia på din Treeview

Postat 2000-12-22 15:10:33 av Pelle Johansson i Kategori Programmering, C#, Kommandon med 0 Kommentarer

Option Explicit
Private Sub Command1_Click()
CopyTreeview TreeView1, TreeView2
End Sub

Private Sub CopyTreeview(objTVSrc As TreeView, objTVDest As TreeView)
'Copies the source treeview to a destination
'treeview. Assumes that both treeviews use the
'same (or identical) ImageLists.

Dim nodeRoot As Node
objTVDest.Nodes.Clear

For Each nodeRoot In objTVSrc.Nodes
If (nodeRoot.Parent Is Nothing) Then
Call CopyTVParentNode(nodeRoot, objTVDest.Nodes)
End If
Next
End Sub


Private Sub CopyTVParentNode(nodeParent As Node, nodesDest As Nodes)
'Walks the specified source parent treeview node,
'and all of it's children nodes, adding them to the
'specified destination Nodes collection.
'
'nodeParent: parent node to walk and copy from
'nodesDest : destination Nodes collection to copy to

Dim nodeDummy As Node
Dim nodeChild As Node

'First add the parent node to the destination nodes collection.
Set nodeDummy = CopyNode(nodeParent, nodesDest)

'Get the current parent node's first child
Set nodeChild = nodeParent.Child

'Now walk through the current parent node's children
'appending the current child node's text to the passed string
Do While Not (nodeChild Is Nothing)

'If the current child node has it's own children...
If nodeChild.Children Then

'Recursively call this proc copying all of it's children
'(it becomes the new parent node)
Call CopyTVParentNode(nodeChild, nodesDest)

Else

'Add the child node to the destination nodes collection.
Set nodeDummy = CopyNode(nodeChild, nodesDest)

End If

'Get the current child node's next sibling
Set nodeChild = nodeChild.Next
Loop
End Sub

Private Function CopyNode(nodeSrc As Node, nodesDest As Nodes) As Node
With nodeSrc
If (.Parent Is Nothing) Then 'Root node
Set CopyNode = nodesDest.Add(, , _
.Key, .Text, _
.Image, .SelectedImage)
CopyNode.Expanded = True
Else 'Child node
Set CopyNode = nodesDest.Add(.Parent.Index, _
tvwChild, _
.Key, .Text, _
.Image, .SelectedImage)
CopyNode.Expanded = True
End If
End With
End Function

Sample:
Size:

Nyligen

  • 09:09 Vill du köpa medicinska tester?
  • 12:47 Vem beviljar assistansen – kommune
  • 14:17 Någon med erfarenhet av hemstädnin
  • 14:14 Bör man använda sig av en båtförme
  • 14:12 Finns det någon intressant hundblo
  • 14:25 Tips på verktyg för att skapa QR-k
  • 14:23 Tips på verktyg för att skapa QR-k
  • 20:52 Fungerer innskuddsbonuser egentlig

Sidor

  • Hem
  • Bli bonusmedlem
  • Läs artiklar
  • Chatta med andra
  • Sök och erbjud jobb
  • Kontakta oss
  • Studentlicenser
  • Skriv en artikel

Statistik

Antal besökare:
Antal medlemmar:
Antal inlägg:
Online:
På chatten:
4 569 159
27 952
271 704
722
0

Kontakta oss

Frågor runt konsultation, rådgivning, uppdrag, rekrytering, annonsering och övriga ärenden. Ring: 0730-88 22 24 | pelle@pellesoft.se

© 1986-2013 PelleSoft AB. Last Build 4.1.7169.18070 (2019-08-18 10:02:21) 4.0.30319.42000
  • Om
  • Kontakta
  • Regler
  • Cookies