Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi,

 

I have a treeview on form (left) and by changing node a different options should show on right. (Something like computer management console)

 

Is there any way to design "sub forms" on right without drawing them trough code?

 

A workaround I used is tabcontrol with hidden tabs.

I know it's a bit "lazy beginner" workaround.

 

Do you know any better way??

 

Thanks

  • *Gurus*
Posted
There isn't really a better way. Personally I use panel controls to host all the different child controls, and hide and show the panel controls as needed. If you attach a panel control to the .Tag of a treenode you can pretty much automate the process too.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Posted

Got Any Examples?

 

If you attach a panel control to the .Tag of a treenode you can pretty much automate the process too

 

Fascinating! Divil, can y0ou provide an example or two of automating that process? I would love to be able to do that with treenodes...

UCM

>-)

  • *Gurus*
Posted

Well, when you create the node you'd set it's tag property, like so:

 

Dim d As New TreeNode("blah")
d.Tag = Panel1
myTreeView.Nodes.Add(d)

 

Then, in the AfterSelect event of the treeview, you'd have to run a loop to hide all visible panel controls on the form, and then show the control associated with the selected node:

 

Dim c As Control

For Each c In Controls
 If typeof c Is Panel Then c.Hide()
Next

DirectCast(e.Node.Tag, Panel).Show()

 

I made that up on the spot and haven't tested it, but something like that should work.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Posted
Someone pointed me to a free tab control at http://www.dotnetmagic.com. This control is better than the standard Windows tab control because you can disable the tab part (the little part that sticks up above the tab page that has some text and possibly an icon) but keep the tab page. Each tab page acts as a container to other objects. You can easily populate each tab page of the control during design mode, switching between tabs as you are designing. Then, you can hide the tabs in run mode and switch between tab pages programatically. There is no need to jack with the visible property of individual controls because only the controls on the active tab page are shown. It is just a matter of setting the "activetab" property (I can't remember what the actual property name is, but it is pretty intuitive) to change the page.
  • *Experts*
Posted

I mentioned a few other possible unwanted side effects to using a 3rd party control, such as dotnetmagic, in this thread.

 

If you don't need the benefits of the control, it's probably better to stick with Panels or a regular tab control. But maybe the dotnetmagic version does some other things he'd like. I like presenting options :)

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted

Makes since guys...

 

The thing about 3rd party "anything", be it a Nintendo controller, memory pack or Microsoft Windows controls; the 3rd party thingy may work just fine, but it may also have errors or problems with it just with normal operation...

 

Of course, if it doesn't then you're rock'in but if it does then it may more of a headache than a solution...Try it, never know till ya do...

 

As a general rule of thumb for me, I'm in agreement with Divil and Nerseus on the subject...

 

What would probably make life much easier is if you used Divil's code above but with a slight modification where instead of showing and hiding panels, just create all of the panels and put them in the exact same location as well as make them all the exact same size...

 

Now you can use the .BringToFront() method as your users click on the nodes...This way you wont have to worry about hiding anything nor checking it's visible properties ;)

UCM

>-)

  • *Experts*
Posted

If you keep them all visible, I think it's more resource intensive than hiding the unused ones. I think windows may still be doing something "extra" behind the scenes as far as processing windows messages. I'm not sure, but it's a guess.

 

As for 3rd party controls, it might be a good idea to see what the company offers in terms of source code. We use controls from DevExpress and they give us FULL C# source code for ALL the controls. Other companies use a repository of sorts that holds the source code in the event they go out of business. By paying a bit extra for the controls, you will get the source code if the company ever goes out of business. This is a nice feature if you're worried about fly-by-night companies and you really don't want to get stuck in a project two years from now with a bug in a 3rd party control...

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...