473,320 Members | 1,991 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

TreeView control

I am trying to create a form so that I can display a high level down to a low level in one column (ALL of Sam's reports, direct and indirect) without having to use code...I am hoping table structure alone will allow this flexibility...does anyone know of any existing examples I could peruse to help???
Feb 8 '07 #1
26 20754
nico5038
3,080 Expert 2GB
Looks to me you need a self-related table like:

ID
IDofParent
FieldX

Now you can place this table e.g. 4 times and connect from the first the IDofParent to the ID of the second, the IDofParent of the second to the ID of the third, etc.

This does require a max of levels, but is doable without code.
The general approach would however bee to use a tree control, but that required advanced VBA skills....

Nic;o)
Feb 8 '07 #2
ADezii
8,834 Expert 8TB
I am trying to create a form so that I can display a high level down to a low level in one column (ALL of Sam's reports, direct and indirect) without having to use code...I am hoping table structure alone will allow this flexibility...does anyone know of any existing examples I could peruse to help???
A TreeView Control would, as Nico stated, graphically display this Hierarchal Structure on a Form and we could also keep its syntax as simple as possible. Give me a sample subset of the data with all Levels defined and I'll post the code for you. Once you see it, I'm sure that you will be able to fill in the blanks.
Feb 9 '07 #3
Expand|Select|Wrap|Line Numbers
  1. Level 1    Level 2    Level 3            Level 4
  2. OPS    SOAR    Provider Service        Provider Services
  3. OPS    SOAR    Provider Service ALL    Reviews
  4. OPS    SOAR    Service Quality        QA
  5. OPS    DOES    Document Operations    NA
  6. OPS    DOES    Process Reengineering    NA
  7. OPS    DOES    Electronic Solutions    ES Support
  8. OPS    DOES    Electronic Solutions    ES Maintenance
  9. Finance    Monroe    ASO            ASO Customer Service
  10. Finance    Monroe    ASO            ASO Claims
  11. Finance    Monroe    ASO            ASO Rewards
  12. Finance    Monroe    PCG            Customer Guarantees
so if i choose a manager from the last row, i should see all individuals for all 3 lower levels in a single row, i.e.:

Monroe + PCG + Customer Gurtantees

if I need to add further info let me know - without code this is a headache inducer...
Feb 9 '07 #4
ADezii
8,834 Expert 8TB
Expand|Select|Wrap|Line Numbers
  1. Level 1    Level 2    Level 3            Level 4
  2. OPS    SOAR    Provider Service        Provider Services
  3. OPS    SOAR    Provider Service ALL    Reviews
  4. OPS    SOAR    Service Quality        QA
  5. OPS    DOES    Document Operations    NA
  6. OPS    DOES    Process Reengineering    NA
  7. OPS    DOES    Electronic Solutions    ES Support
  8. OPS    DOES    Electronic Solutions    ES Maintenance
  9. Finance    Monroe    ASO            ASO Customer Service
  10. Finance    Monroe    ASO            ASO Claims
  11. Finance    Monroe    ASO            ASO Rewards
  12. Finance    Monroe    PCG            Customer Guarantees
so if i choose a manager from the last row, i should see all individuals for all 3 lower levels in a single row, i.e.:

Monroe + PCG + Customer Gurtantees

if I need to add further info let me know - without code this is a headache inducer...
I will get back to you on this shortly.
Feb 10 '07 #5
ADezii
8,834 Expert 8TB
I will get back to you on this shortly.
Hang on to your seat belts and follow these instructions exactly:
__01 Create a New, Unbound Form.
__02 Place a TreeView Control on the Form via Insert ==> ActiveX Control ==> Microsoft TreeView Control.
__03 Size the Control to the full Form dimensions.
__04 Rename the TreeView Control to TreeView1. If it is named anything other than this, the code will not be functional.
__05 Place the following code in the Form's Load() Event (listed below).
__06 When the Form opens, you will see the Root and Level1 Nodes. You can now see your Hierarchal structure by Expanding/Collapsing (+/-) various branches to move Up and Down multiple Levels as in Windows Explorer.
__07 Each Level in the code has its own degree of indentation to make your understanding of the coding process easier so that you may adapt the code to your own specific needs.
__08 If you have any questions, feel free ask as the TreeView Control is a fairly complex Control to implement.
__09 If you are interested, you can also display Icons for each individual Node but this involves inserting an ImageList Control, assigning Icons to it, pointing the TreeView Control to it, and setting Index values for each Icon for each line of code.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. Dim nodX As Node
  3.  
  4. '1-Relative, tvwChild-Relationship, "g"-Key, "George"-Text
  5. Set nodX = TreeView1.Nodes.Add(, , , "Hierarchal Structure Example (ROOT)") 'Root of Treeview Control
  6.  
  7. Set nodX = TreeView1.Nodes.Add(1, tvwChild, "Topic1", "OPS")
  8.   Set nodX = TreeView1.Nodes.Add("Topic1", tvwChild, "Level2A", "SOAR")
  9.     Set nodX = TreeView1.Nodes.Add("Level2A", tvwChild, "Level3A", "Provider Service")
  10.       Set nodX = TreeView1.Nodes.Add("Level3A", tvwChild, "Level4A", "Provider Services")
  11.       Set nodX = TreeView1.Nodes.Add("Level3A", tvwChild, "Level4B", "ALL Reviews")
  12.     Set nodX = TreeView1.Nodes.Add("Level2A", tvwChild, "Level3B", "Service Quality")
  13.       Set nodX = TreeView1.Nodes.Add("Level3B", tvwChild, "Level4C", "QA")
  14.   Set nodX = TreeView1.Nodes.Add("Topic1", tvwChild, "Level2B", "DOES")
  15.     Set nodX = TreeView1.Nodes.Add("Level2B", tvwChild, "Level3C", "Document Operations")
  16.       Set nodX = TreeView1.Nodes.Add("Level3C", tvwChild, "Level4D", "NA")
  17.     Set nodX = TreeView1.Nodes.Add("Level2B", tvwChild, "Level3D", "Process Engineering")
  18.       Set nodX = TreeView1.Nodes.Add("Level3D", tvwChild, "Level4E", "NA")
  19.     Set nodX = TreeView1.Nodes.Add("Level2B", tvwChild, "Level3E", "Electronic Solutions")
  20.       Set nodX = TreeView1.Nodes.Add("Level3E", tvwChild, "Level4F", "ES Support")
  21.       Set nodX = TreeView1.Nodes.Add("Level3E", tvwChild, "Level4G", "ES Maintenance")
  22. Set nodX = TreeView1.Nodes.Add(1, tvwChild, "Topic2", "Finance")
  23.   Set nodX = TreeView1.Nodes.Add("Topic2", tvwChild, "Level2C", "Monroe")
  24.     Set nodX = TreeView1.Nodes.Add("Level2C", tvwChild, "Level3F", "ASO")
  25.       Set nodX = TreeView1.Nodes.Add("Level3F", tvwChild, "Level4H", "ASO Customer Service")
  26.       Set nodX = TreeView1.Nodes.Add("Level3F", tvwChild, "Level4I", "ASO Claims")
  27.       Set nodX = TreeView1.Nodes.Add("Level3F", tvwChild, "Level4J", "ASO Rewards")
  28.     Set nodX = TreeView1.Nodes.Add("Level2C", tvwChild, "Level3G", "PCG")
  29.       Set nodX = TreeView1.Nodes.Add("Level3G", tvwChild, "Level4K", "Customer Guarantees")
  30.  
  31.     nodX.EnsureVisible
  32.  
  33. TreeView1.Nodes(1).ForeColor = QBColor(4)
  34.  
  35. Exit_Form_Load:
  36.   Exit Sub
  37.  
  38. Err_Form_Load:
  39.   MsgBox Err.Description, vbExclamation, "Error in TreeView_Form_Load()"
  40.   Resume Exit_Form_Load
  41. End Sub
Feb 11 '07 #6
WOW - I knew it wouldn’t' be easy - I follow you to a point - in your instructions I don't see anything tying the code to my table – or am I just putting the layout and table data directly in the code itself as you have done with the few examples I provided?
Feb 12 '07 #7
ADezii
8,834 Expert 8TB
WOW - I knew it wouldn’t' be easy - I follow you to a point - in your instructions I don't see anything tying the code to my table – or am I just putting the layout and table data directly in the code itself as you have done with the few examples I provided?
This is simlpy hard-coded values to give you an idea of how this Control functions. Reading values from a Table/Recordset wopuold add complexity to the coding.
Feb 12 '07 #8
Thanks - this code worked perfect!!!
Feb 13 '07 #9
ADezii
8,834 Expert 8TB
Thanks - this code worked perfect!!!
Glad to help you.
Feb 13 '07 #10
hey guys, glad to see the code working, but i can't really find where is the activex control in vba. Please advise.

Thanks
Oct 16 '08 #11
ADezii
8,834 Expert 8TB
hey guys, glad to see the code working, but i can't really find where is the activex control in vba. Please advise.

Thanks
  1. Form Design View.
  2. Insert.
  3. ActiveX Control.
  4. You are now in the Insert ActiveX Control Dialog Box.
  5. Select the Microsoft TreeView Control, version X.X.
  6. The TreeView Control should now exist in the Upper Left Hand corner of the Form.
Oct 16 '08 #12
Thanks so much. it took me a while. :D There is one more thing that i dont know if the treeview can do. For ex, if im gonna select Service Quality ( Under OPS-SOAR), will it be possible to make a button that will copy the hierachy into the following format: OPS/ SOAR/ Service Quality?

Thanks so much man. you are the man
Oct 17 '08 #13
ADezii
8,834 Expert 8TB
Thanks so much. it took me a while. :D There is one more thing that i dont know if the treeview can do. For ex, if im gonna select Service Quality ( Under OPS-SOAR), will it be possible to make a button that will copy the hierachy into the following format: OPS/ SOAR/ Service Quality?

Thanks so much man. you are the man
Yes, it should be no problem. They wouold simply be Children of Parent Nodes, follow the examples.
Oct 17 '08 #14
Thank you, i probably didn't make myself clear enough. It is a lil bit confusing for me.

I have successfully constructed the tree, but the information that is useful for the end user if they can extract the information out of the tree and use it.

Using the treview that we have here as an example, if I want to select service quality (which is under OPS and SOAR), is there a way to extract the levels i have go through in a text string that can look something like this:

OPS/ SOAR/ Service Quality

On the same line, if I want to convert to text string just SOAR ( under OPS), it will give me OPS/SOAR ?

and hopefully the same thing will happen if i click something else in the treeview.

I dont know if this can be accomplished by using buttons and text boxes or using something else.

Please help. I really Appreciate it. you are the man
Oct 17 '08 #15
ADezii
8,834 Expert 8TB
Thank you, i probably didn't make myself clear enough. It is a lil bit confusing for me.

I have successfully constructed the tree, but the information that is useful for the end user if they can extract the information out of the tree and use it.

Using the treview that we have here as an example, if I want to select service quality (which is under OPS and SOAR), is there a way to extract the levels i have go through in a text string that can look something like this:

OPS/ SOAR/ Service Quality

On the same line, if I want to convert to text string just SOAR ( under OPS), it will give me OPS/SOAR ?

and hopefully the same thing will happen if i click something else in the treeview.

I dont know if this can be accomplished by using buttons and text boxes or using something else.

Please help. I really Appreciate it. you are the man
You could extract all Children of Main Node and concatenate the result as in: Main Node/Child 1/Child 2/Child 3/...etc.
Is this what you are looking for? If it is you can Reference the Help Files for the Child and Parent properties. If you still have difficulties, let me know.
Oct 17 '08 #16
I hope you can see the tree that i just made.




One that tree, i created a submit button (it can't do anything yet), but i would love if it can extract from my selection.

In this ex, i select professional by going through legal- professional, when i click submit button, it should return the string "legal/ professional" like in the example


http://www.flickr.com/photos/31626245@N06/2959564798/


similarly, for automobile, if i click automobile and then submit, it will return the string " automobile" in the box.

http://www.flickr.com/photos/31626245@N06/2959569056/

Is there any ways to accomplish this?

Thanks
Oct 20 '08 #17
ADezii
8,834 Expert 8TB
I hope you can see the tree that i just made.




One that tree, i created a submit button (it can't do anything yet), but i would love if it can extract from my selection.

In this ex, i select professional by going through legal- professional, when i click submit button, it should return the string "legal/ professional" like in the example


http://www.flickr.com/photos/31626245@N06/2959564798/


similarly, for automobile, if i click automobile and then submit, it will return the string " automobile" in the box.

http://www.flickr.com/photos/31626245@N06/2959569056/

Is there any ways to accomplish this?

Thanks
It'as probably a lit simpler than you realize, the the NodeClick() Event of the treeView Control, place the following code for a visual cue:
Expand|Select|Wrap|Line Numbers
  1. Private Sub TReeview1_NodeClick(ByVal Node As Object)
  2.   MsgBox Replace(Node.FullPath, "\", "/")
  3. End Sub
Oct 20 '08 #18
It'as probably a lit simpler than you realize, the the NodeClick() Event of the treeView Control, place the following code for a visual cue:
Expand|Select|Wrap|Line Numbers
  1. Private Sub TReeview1_NodeClick(ByVal Node As Object)
  2.   MsgBox Replace(Node.FullPath, "\", "/")
  3. End Sub
Wow thats only a 3 line of codes. lol Thanks man, but i have a compiler error saying that " procedure declaration does not match description of event or procedure having the same name".. that sucks.

So I went ahead trying to find solutions for this compiler error, but nothing is really showing up.

Crap, so I created a label so i can show this, using the following code

Label1.Caption = nodX.FullPath

(nodX is the variable)

Well, it shows, but it only shows the last one, and it did not show anything else when i click through nodes. Is there any updates can be done, or even an If function might be helpful.

Thanks
Oct 21 '08 #19
ADezii
8,834 Expert 8TB
Wow thats only a 3 line of codes. lol Thanks man, but i have a compiler error saying that " procedure declaration does not match description of event or procedure having the same name".. that sucks.

So I went ahead trying to find solutions for this compiler error, but nothing is really showing up.

Crap, so I created a label so i can show this, using the following code

Label1.Caption = nodX.FullPath

(nodX is the variable)

Well, it shows, but it only shows the last one, and it did not show anything else when i click through nodes. Is there any updates can be done, or even an If function might be helpful.

Thanks
The correct syntax in the NodeClick() Event is:
Expand|Select|Wrap|Line Numbers
  1. Me![Label1].Caption = Node.FullPath
Oct 21 '08 #20
The correct syntax in the NodeClick() Event is:
Expand|Select|Wrap|Line Numbers
  1. Me![Label1].Caption = Node.FullPath
So should i use the IF loop for this? I tries to implement the code in various lines, but the label only shows the node that is above this code.

Is there anyways to show the appropriate path when choosing any specific node?

Thanks
Oct 21 '08 #21
ADezii
8,834 Expert 8TB
So should i use the IF loop for this? I tries to implement the code in various lines, but the label only shows the node that is above this code.

Is there anyways to show the appropriate path when choosing any specific node?

Thanks
Yes, by using either an If...ElseIf...Else...End If, or Select Case Structure. It all depends on which Nodes you want to exclude.
Oct 21 '08 #22
Yes, by using either an If...ElseIf...Else...End If, or Select Case Structure. It all depends on which Nodes you want to exclude.
ADezii,

I want to inlcude every node. But only when i select them, it will show the full path. Please advice on how to use if properly for this treeview.

Thanks
Oct 21 '08 #23
ADezii
8,834 Expert 8TB
ADezii,

I want to inlcude every node. But only when i select them, it will show the full path. Please advice on how to use if properly for this treeview.

Thanks
The code as it is now, placed in the NodeClick() Event will activate 'only' when the Node is Clicked/Selected. I don't know what else to tell you.
Oct 21 '08 #24
The code as it is now, placed in the NodeClick() Event will activate 'only' when the Node is Clicked/Selected. I don't know what else to tell you.
Thanks, ADezii,

I found the solution for this. This following code works:

Private Sub Tree_NodeClick(ByVal Node As MSComctlLib.Node)

Me.Label1.Caption = Node.FullPath
End Sub

I have no Idea why we have to use the MSComctLib.Node, but it shows the path perfectly.

Thanks so much for helping me with this VBA. I really appreciate it.
Oct 22 '08 #25
Thanks, ADezii,

I found the solution for this. This following code works:

Private Sub Tree_NodeClick(ByVal Node As MSComctlLib.Node)

Me.Label1.Caption = Node.FullPath
End Sub

I have no Idea why we have to use the MSComctLib.Node, but it shows the path perfectly.

Thanks so much for helping me with this VBA. I really appreciate it.
ADezii,

Its maybe really easy, but I just can't seem to find a way to record that path I show into the textbox and then add another fullpath into the same textbox. Any advice?
Oct 22 '08 #26
ADezii
8,834 Expert 8TB
ADezii,

Its maybe really easy, but I just can't seem to find a way to record that path I show into the textbox and then add another fullpath into the same textbox. Any advice?
I'm assuming that you mean to add another Full Path to the Label Control which already contains a Full Path, if so:
Expand|Select|Wrap|Line Numbers
  1. Me.Label1.Caption = Me.Label1.Caption  & "\" & Node.FullPath
Oct 23 '08 #27

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Jim | last post by:
The below problem occurs randomly too, but I've managed to isolate a sequence of events when it always happens: I have two forms (say Form1 and Form2). Form 1 contains a TreeView control. A...
5
by: SoKool | last post by:
Can anyone point me to a site where I can get a free treeview control to use in ASP .NET or any tutorial that can help me build my own treeview control. I intend to use a treeview to generate a...
1
by: Srinivasa Raghavan | last post by:
Hi All, I have some doubts on the Treeview control and Form Authentication 1) will Form Authentication work if cookies are disabled. 2) I have problem in the following code (TreeView...
2
by: Chris | last post by:
Hi, anyone experience with the TreeView control that is available in the Microsoft.Web.UI.WebControls component ? I want to add a few nodes to the TreeView-control but don't know quite how :...
3
by: Peter | last post by:
Hello, We are inserting a side menu to our application using a class that is writing HTML on all our pages. This is a part of the code as an example: writer.Write(" <table WIDTH=""100%""...
4
by: Ben Coats | last post by:
Hey, I'm trying to find code for an Explorer-style Directory ComboBox. (You know, it display "Desktop", "My Computer", all drives, etc., but it has a treeview control inside the combobox so that...
10
by: p3t3r | last post by:
I have a treeview sourced from a SiteMap. I want to use 2 different CSS styles for the root level nodes. The topmost root node should not have a top border, all the other root nodes should have a...
5
by: david | last post by:
I do not know if there is a treeView control for web form in .NET 1.1. I know there is IE Webcontrol package which has the treeview control for ..net 1.0. I have tested it in .net 1.1 before. It...
0
by: noneya22 | last post by:
I want to use a TreeView control as a one-level, vertical navigation menu. I'm using this control currently with a SiteMapDataSource and .sitemap file. I've written code that associates an image...
1
by: echuck66 | last post by:
Hi, I have a Winforms 2.0 project that I'm working on that involves populating a treeview control from data contained in a fairly large dataset that has to be refreshed periodically. I have no...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.