Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 2nd, 2005, 06:24 AM
Registered User
 
Join Date: May 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Switching User Controls with NavBar

hej,

i'm looking for a solution to control multiplie user controls by clicking on on an item in the navbar, located at the left side
of the screen.

I can handle the NavBar, that's fine. Writing a Click Event for
each item in the NavBar seems to be the most convinient solution to
call a user control and display it alongside the navbar.

The problem: So far i simply dragged all my user controls on the form
and worked with the "visible" proprety

private void navItemAdresses_LinkClicked(object sender, MyNavbar.NavBarLinkEventArgs e)
{
usercontrol.Visible = true;
usercontrol1.Visible = false;
....
}

That's a really s... solution. Can anyone suggest me a better one?







 
Old May 2nd, 2005, 10:13 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

As bad as it might seem, that's how you do it!

If your navbar has some state property you can test off of then you could simplify it a little bit:

usercontrol.Visible = navTabs.SelectedTab == 1;
usercontrol1.Visible = navTabs.SelectedTab == 2;

You can put this in the page prerender event handler so you don't have to wire in all the tests to the tab onclick methods. This is usually how I approach multi-mode pages.

-Peter
 
Old May 3rd, 2005, 10:48 AM
Registered User
 
Join Date: May 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

well, it seems to be an easy solution, but consider
that the user launches a series of user controls by
clicking on the items in the navbar.

I looked on the web and discovered that there is a BringToFront()
mehtod. But it didn't work, because i need to determine which
user controls have a "visibility= true" and apply the mehtod
SetToBack() or set the visibility to false to all of them (all user controls which status is actually true)

Any idea how to implement this?



Quote:
quote:Originally posted by planoie
 As bad as it might seem, that's how you do it!

If your navbar has some state property you can test off of then you could simplify it a little bit:

usercontrol.Visible = navTabs.SelectedTab == 1;
usercontrol1.Visible = navTabs.SelectedTab == 2;

You can put this in the page prerender event handler so you don't have to wire in all the tests to the tab onclick methods. This is usually how I approach multi-mode pages.

-Peter
 
Old May 3rd, 2005, 11:08 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

This is a winforms application? My initial reply was with the thinking it was webforms. I'm not sure what the best way is in a winforms environment.

-Peter
 
Old May 4th, 2005, 02:57 AM
Registered User
 
Join Date: May 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm sorry, that i didn't clearly mention that it is a windows forms
application.








Similar Threads
Thread Thread Starter Forum Replies Last Post
User controls' content: Chapter 2 User Controls AGS BOOK: Professional ASP.NET 2.0 Server Control and Component Development ISBN: 978-0-471-79350-2 10 July 26th, 2007 05:36 AM
User Controls Duncan Pro VB.NET 2002/2003 1 October 27th, 2003 12:51 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.