Using treeview in a form
-
QUESTION: I was wondering if you could help me out with something. I'm not very experienced in VB so for the most part I have no clue to what I'm doing. I have a MS SQL server that stores requests for our Projects and their SubProjects. I¡¯m trying to get anSheet to create a report for an individual project to show different types of counts for the request. I have been able to get the Workbook to do the following: 1. Connect to the SQL server and return a listing of projects that the user belongs to 2. Display the Projects in a form so the user can select a project 3. Based off the project selected, get the projects¡¯ SubProject folder structure from the SQL server and store this structure in on sheet ¡°Config2¡±, Columns E:J My Issue is I would like to use this folder structure to populate a TreeView. I¡¯m trying to use ¡° Microsoft TreeView Control, Version 6.0¡± but have no clue how to do this. Here is example data for the structure I get from the server: Project ID ParentID Parent Name ChildID Child Name Display Order 1269 0 N/A 3185 Sub 1 1 1269 0 N/A 3187 Sub 2 2 1269 3185 Sub 1 3189 Sub 1.Child 1 1 1269 3185 Sub 1 3190 Sub 1.Child 1 2 1269 3185 Sub 1 3191 Sub 1.Child 1 3 1269 3187 Sub 2 3194 Sub 2.Child 1 1 1269 3187 Sub 2 3195 Sub 2.Child 2 2 If the parent ID is 0 then the Child is the top level folder under the project. If the Parent ID is > 0 then the number is the folder ID that the Child is under. I¡¯m also looking at trying to have the tree view have specific control functions like: 1. If a Parent is selected/deselected, All child folder are selected/deselected 2. Only the names are displayed in the TreeView 3. When the OK/Select Button on the form is selected all the Child ID¡¯s that are selected are stored in a single cell, but they are stored as comma delimited I¡¯m know this is a lot but any help or direction would be greatly appreciated ANSWER: Shawn, the microsoft treeview control is not distributed withand isn't part of Excel, so I don't really have any experience working with it. In addition to your question, today I had a question on getting attachments fromemails, and using VBA to get information from web pages. While all these things can be done from Excel, they can also be done from the stand alone VBA development environment, any application that supports VBA or even almost any language that supports object linking and embedding (OLE). There is nothing about doing those things that is directly related to Excel. I only say this to emphasize that this isn't anquestion even though you might want to perform the action inand if I happened to have any expertise with it, I certainly would attempt to help you. Unfortunately, I don't. Ole Erlandsen has a sample workbook that sounds like it has some sample code similar to what you want. Hopefully that will give you the information you need: http://www.erlandsendata.no/english/index.php?d=endownloaduserforms read down the page and you will see a link to a workbook with a treeview implementation. So sorry, but I have never attempted to use a Treeview control. My expertise is in usingto dorelated things. Sorry. ---------- FOLLOW-UP ---------- QUESTION: Thanks for giving this a look. I have actually seen this example before. It was what got me to look at doing this TreeView. Problem with the example is it has the folder structure hard coded in the in the form. I need to call it from a worksheet. I'll keep pocking around to see what I can come up with. Thanks again for your help ANSWER: Shawn, you might ask Jan Karel Pieterse in this forum. I have seen him answer questions on Treeview controls. ---------- FOLLOW-UP ---------- QUESTION: I'll Give Him a try, Another question: Do you know if you can Disable the Save and Save as Functions?
-
Answer:
Shawn, one way would be to use the beforesave event. It has an argument called Cancel. If you set Cancel = False in the event, then the save won't take place. Like so many protections, if they are based on code, the user can easily disable code and it all goes away - even treeview controls. If you have2003 or earlier (down to xl97) you can alter the commandbars so the save and saveas button are not visible, but this will not prevent Ctrl + S If you are using a workbook as a template, then you might do that - use it as a template. Or you might make it an addin so they the user isn't ever actually in your workbook. Jan Karl P. also has an article on distributing an application that might have some good information for you: http://www.jkp-ads.com/articles/DistributeMacro00.asp if you are using xl2007 or later, then he ribbon is quite another challenge. I am just reading a book on modifying the ribbon, so I really can't tell you much about that other than it is really complicated. Also, if you don't get what you need from Jan and you think Ole's solution is basically what you want, I can probably take what you want and modify his stuff to do what you want. You would need to send a sample workbook with a good explanation of what you want. It wouldn't necessarily be an overnight solution.
Miningco.com Visit the source
Related Q & A:
- How to submit a form using httpurlconnection?Best solution by stackoverflow.com
- how to add a form with a unique id on jquery?Best solution by Stack Overflow
- Do you think children sometimes use humor as a form of self-healing for psychological trauma(s?Best solution by Yahoo! Answers
- If I have a form, such as an application, how can I fill it out using my computer?Best solution by answers.yahoo.com
- What is an easy code for a form in PHP?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.