Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Viewing Forms from a TreeView Control

Posted on 2004-09-10
7
Medium Priority
?
207 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
Independent Software Vendors: 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

604 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