Results 1 to 18 of 18

Thread: treeview

  1. #1
    dana340
    Guest

    treeview

    hello there,
    how can i create treeview and use it to open form1 and form2 while running the program,
    i need the codes.
    i know someone done it before,
    thanks



    I'm on line

  2. #2
    gaffa
    Guest
    ***???

    You are going to have to be a lot more specific - I've got no idea what you are actually asking. Rephrase the question (and add a bit more detail), and I'll try to help.

    - gaffa

  3. #3
    Fanatic Member dongaman's Avatar
    Join Date
    Aug 2001
    Location
    xi'an
    Posts
    616
    how can i create treeview and use it to open form1 and form2 while running the program
    ??????
    Can not understand
    I am just aman.

  4. #4
    dana340
    Guest
    ok gaffa,
    i use to add commands buttons as

    Private Sub cmd1_click()
    form1.show
    end sub

    Private Sub cmd2_click()
    form2.show
    end sub

    so instead of using these codes and buttons
    i was thinking to use treeview to show either form1
    or form2 when i click on the name of the form
    i hope this is clear
    thanks.

  5. #5
    Addicted Member E-Link's Avatar
    Join Date
    Nov 2001
    Location
    INA
    Posts
    242
    hi ,
    add treeview to ur form , and type this code :

    Code:
    Private Sub Form_Load()
    
    TreeView1.Nodes.Add , , "K1", "Available Form"
    TreeView1.Nodes(1).Expanded = True
    For i = 1 To 10
        TreeView1.Nodes.Add "K1", tvwChild, , "Form -" & i
    Next
    End Sub
    
    
    Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
    MsgBox Node.Text
    Select Case Node.Text
        Case "Form -1":  'do something here
        Case "Form -2": 'do
        'etc
    End Select
    End Sub
    BTW, Is Ur Name LINA?

  6. #6
    dana340
    Guest
    thanks for the reply,
    i have copy ur codes but, i have error as
    variable not defined

    For i = 1 To 10

    I'm on line

  7. #7
    Addicted Member E-Link's Avatar
    Join Date
    Nov 2001
    Location
    INA
    Posts
    242
    add DIm i as Integer at the top

  8. #8
    dana340
    Guest

    Wink

    thanks that was greatfull,

    Who can crack This :
    Q33NY change the font to Wingdings
    thanks any way

  9. #9
    dana340
    Guest
    ok E-Link,

    one more thing,
    when i click on the treeview for form1 it works good but,
    how can i make the msgbox "opening form 1" , when i have more than one form ,form1 as (sea) , form 2 as
    (sand), form3 as (sky), and so on,
    pls. advice
    thanks for the help


    I'm on line

  10. #10
    dana340
    Guest

    Thumbs up

    ok E-Link,

    second time asking,
    i wonder if the msgbox can display the form name when clicking on the treeview using the codes on tops.
    pls. someone help

  11. #11
    Frenzied Member
    Join Date
    Aug 2001
    Posts
    1,075
    VB Code:
    1. Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
    2. 'I think the MsgBox would be annoying to anyone using your program
    3. MsgBox "Opening " & Node.Text
    4. Select Case Node.Text
    5.     Case "Form -1":  Form1.Show
    6.     Case "Form -2": Form1.Show
    7. End Select
    8. End Sub

    Greg
    PS
    Q33NY change the font to Wingdings
    This is stupid and meaningless.
    Free VB Add-In - The Reference Librarian
    Click Here for screen shot and download link.

  12. #12
    dana340
    Guest
    fisrt thanks for your reply,
    second ( Q33NY change the font to Wingdings
    ) that was [ E-Link ] quote: asking who can crack this, was not mine,

    third i have tried your codes and i'm getting the same result
    becuase i was asking if i have qnty2 forms
    1:-form1 named as sky , form2 named as sand,
    2:- the msgbox will display this ( opening form1), which i know ,
    again i want the msgbox to display the form name , and i know the msgbox how to be used in normal ways)
    i hope my request is clear,
    thank u

  13. #13
    Frenzied Member
    Join Date
    Aug 2001
    Posts
    1,075
    Instead of the loop

    VB Code:
    1. For i = 1 To 10
    2.     TreeView1.Nodes.Add "K1", tvwChild, , "Form -" & i
    3. Next

    You need to add each form to the treeview
    VB Code:
    1. TreeView1.Nodes.Add "K1", tvwChild, , "frmSky"
    2.     TreeView1.Nodes.Add "K1", tvwChild, , "frmWater"
    3.     TreeView1.Nodes.Add "K1", tvwChild, , "frmLand"

    Also change the Select Case block to check for these form names instead of Form -1, Form -2, etc

    Greg
    Free VB Add-In - The Reference Librarian
    Click Here for screen shot and download link.

  14. #14
    dana340
    Guest

    Talking

    gdebacker,

    that was greatful, thanks for the help

  15. #15
    dana340
    Guest
    gdebacker,
    happy new year to evey body

    after set project > refrance > microsoft window common control 2 6.0 (sp3).
    i used this codes but i maight done some thing wrong
    i have error on codes below pls. check

    Set NODX = TreeView1.Nodes.Add(, , "RP", "SUBJECT")



    Private Sub Form_Load()
    Dim NODX As Node

    Set NODX = TreeView1.Nodes.Add(, , "RP", "SUBJECT")
    Set NODX = TreeView1.Nodes.Add("RP", tvwChild, "C1", "CALCULATION")
    Set NODX = TreeView1.Nodes.Add("C1", tvwChild, "C2", "FOOD")
    Set NODX = TreeView1.Nodes.Add("C2", tvwChild, "C19", "FOOD DETAILL")

    Set NODX = TreeView1.Nodes.Add("C1", tvwChild, "C3", "KIDS")
    Set NODX = TreeView1.Nodes.Add("C3", tvwChild, "C20", "KIDS DETAILL")

    Set NODX = TreeView1.Nodes.Add("C1", tvwChild, "C4", "MAIDS")
    Set NODX = TreeView1.Nodes.Add("C4", tvwChild, "C21", "MAIDS DETAILL")

    Set NODX = TreeView1.Nodes.Add("C1", tvwChild, "C5", "CARS")
    Set NODX = TreeView1.Nodes.Add("C5", tvwChild, "C22", "CARS DETAILL")

    Set NODX = TreeView1.Nodes.Add("C1", tvwChild, "C6", "OTHERS")
    Set NODX = TreeView1.Nodes.Add("C6", tvwChild, "C23", "OTHERS DETAILL")

    Set NODX = TreeView1.Nodes.Add("RP", tvwChild, "C7", "INFORMATIONS")
    Set NODX = TreeView1.Nodes.Add("C7", tvwChild, "C8", "TELEPHONE")
    Set NODX = TreeView1.Nodes.Add("C7", tvwChild, "C9", "DOCUMENTS")
    Set NODX = TreeView1.Nodes.Add("C7", tvwChild, "C10", "BILLS")
    Set NODX = TreeView1.Nodes.Add("C7", tvwChild, "C11", "REMARKS")


    Set NODX = TreeView1.Nodes.Add("RP", tvwChild, "C12", "REPORTS")
    Set NODX = TreeView1.Nodes.Add("C12", tvwChild, "C13", "GENERAL")

    'Set NODX = TreeView1.Nodes.Add("C13", tvwChild, "C14", "FOOD DETAILL")
    'Set NODX = TreeView1.Nodes.Add("C13", tvwChild, "C15", "KIDSD DETAILL")
    'Set NODX = TreeView1.Nodes.Add("C13", tvwChild, "C16", "OTHERS DETAILL")
    'Set NODX = TreeView1.Nodes.Add("C13", tvwChild, "C17", "CARS DETAILL")
    'Set NODX = TreeView1.Nodes.Add("C13", tvwChild, "C18", "MAIDS DETAILL")


    Set NODX = TreeView1.Nodes.Add("RP", tvwChild, "C24", "EXIT")
    TreeView1.LineStyle = tvwRootLines
    End Sub
    Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
    'MsgBox "Opening " & Node.Text

    Select Case Node.Text
    Case "EXIT": MsgBox " WANT TO EXIT", , "ECO": End

    Case "OTHERS": OTHERS.Show: FOOD.Hide: KIDS.Hide: MAIDS.Hide: CARS.Hide: frmresult.Show: frmtreeview.Show 'do
    Case "KIDS": KIDS.Show: FOOD.Hide: OTHERS.Hide: MAIDS.Hide: OTHERS.Hide: frmresult.Show: frmtreeview.Show 'do
    Case "MAIDS": MAIDS.Show: FOOD.Hide: OTHERS.Hide: CARS.Hide: KIDS.Hide: frmresult.Show: frmtreeview.Show 'do
    Case "FOOD": FOOD.Show: MAIDS.Hide: OTHERS.Hide: KIDS.Hide: CARS.Hide: frmresult.Show: frmtreeview.Show 'do
    Case "CARS": CARS.Show: MAIDS.Hide: OTHERS.Hide: KIDS.Hide: FOOD.Hide: frmresult.Show: frmtreeview.Show 'do
    End Select
    TreeView1.LineStyle = tvwRootLines
    End Sub


    I'M on line

  16. #16
    Addicted Member E-Link's Avatar
    Join Date
    Nov 2001
    Location
    INA
    Posts
    242
    maybe u must use sp4

  17. #17
    dana340
    Guest
    i don't have the (sp4)
    from where u got it
    i have got only> window common control 2 6.0 (sp3).
    on vb.6

    maybe gdebacker could advice
    thanks for the reply any way


  18. #18
    Frenzied Member
    Join Date
    Aug 2001
    Posts
    1,075
    I was able to run your Form_Load() code to create the TreeView Nodes. What error do you receive? You should get an Error Number and an Error Description.

    Greg
    Free VB Add-In - The Reference Librarian
    Click Here for screen shot and download link.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width