?
Solved

Viewing Forms from a TreeView Control

Posted on 2004-09-10
7
Medium Priority
?
206 Views
Last Modified: 2010-04-23
I would like to build all of my form navigation into a treeview control that is load from a database (Sql server).  I have a user, Jon Doe, as the base node and beneath him are the nodes that he has access to view, i.e., Form1, Form2, Form3, etc.  However, I'm not sure how to reference the value of the treeview node, "Form1", to my actual Form1 in solutions explorer.

Please advice

Rookie
0
Comment
Question by:RookieTim
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 19

Expert Comment

by:arif_eqbal
ID: 12033409
Well what I understand is that you would show a list of all forms a particular user has access to on a TreeView and when the user clicks on them you would open that form. If this is what you want and you are using VB.NET

Load the TreeView with the Names of All Forms as Nodes eg. Form1,Form2 etc.

Now on AfterSelect event of TreeView call a Function ShowForm and Pass the name of the form i.e. the TExt of the Node

Now in the function use Select Case on the Names to create reference of the particular form and show it....
0
 
LVL 8

Accepted Solution

by:
wguerram earned 2000 total points
ID: 12035182
Hope this helps.

You can add your form names to the tag property of the node and in the after select event you can create an instance of the form like this:

dim f as Object
f = System.Activator.CreateInstance(Type.GetType(node.Tag))

if not isnothing(f) then
   f .Show
end if

I think you have to add the namespace and form name, i don't access to vb now.

node.Tag = "MyNameSpace.Form1"

Check in the project properties to see the name space.

Hope this helps.
0
 
LVL 8

Expert Comment

by:wguerram
ID: 12044060
This the code for creating the form

Remember that when adding the form name, you also have to add the form namespace

dim _node as new node

_node.Tag = "MayNameSpace.Form1"

TreeView1.Nodes.Add(_node)

'------------------
Dim f As Object

f = Activator.CreateInstance(Type.GetType(node.Tag, True))

If you have problems, please let me know it.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:RookieTim
ID: 12058735
Wguerram-

This is works well.  However, my problem is that I want just a single instance of a form open at a given time?  Do you have a suggestion on how to maintain just one instance.

I was anticipating using this block of code, but it dosen't seem to be working as well as I'd have hoped.


' MyChildForm is the one I'm looking for which would be f in our instance
 
    Dim childForm As MyChildForm =  Nothing
    Dim c As Form
 
    For Each c In Me.MdiChildren
           If TypeOf c Is MyChildForm Then
               ' found it
               childForm = CType(c, MyChildForm)
               Exit For
          End If
     Next
 
     If Not childForm Is Nothing Then
          childForm.Show()
          childForm.Focus()
     Else
          childForm = New MyChildForm()
          childForm.MdiParent = Me
          childForm.Show()
          childForm.Focus()  
     End If
 
0
 
LVL 8

Expert Comment

by:wguerram
ID: 12058813
0
 

Author Comment

by:RookieTim
ID: 12077584
Thank you very much.
0
 
LVL 8

Expert Comment

by:wguerram
ID: 12078075
You're welcome!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question