473,671 Members | 2,568 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

panels interfere with each other

EntryTeam
55 New Member
I've got this problem, i have 3 panels inside groupbox. all 3 panel are placed one over the other. when i make one of them visible, the other two SHOULD not be visible or interfere with the visible one.
The panels are started form menu strip.

But it's not working. Please, check my code, i really need advice:
Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. using System.Windows.Forms;
  5.  
  6. namespace dugma1
  7. {
  8.     public partial class MainForm : Form
  9.     {
  10.         public MainForm()
  11.         {
  12.             InitializeComponent();
  13.             groupBox1.Visible=false;
  14.             panel1.Visible=false;
  15.             panel2.Visible=false;
  16.             panel3.Visible=false;
  17.         }
  18.  
  19.         void N1ToolStripMenuItemClick(object sender, EventArgs e)
  20.         {
  21.             groupBox1.Visible=true; panel1.Visible=true; 
  22.  
  23.             panel2.Visible=false; panel3.Visible=false;
  24.         }
  25.  
  26.         void N2ToolStripMenuItemClick(object sender, EventArgs e)
  27.         {
  28.             groupBox1.Visible=true; panel2.Visible=true; 
  29.  
  30.             panel1.Visible=false; panel3.Visible=false;
  31.         }
  32.  
  33.         void N3ToolStripMenuItemClick(object sender, EventArgs e)
  34.         {
  35.             groupBox1.Visible=true; panel3.Visible=true; 
  36.  
  37.             panel1.Visible=false; panel2.Visible=false;
  38.         }
  39.  
  40.         void Button1Click(object sender, EventArgs e)
  41.         {
  42.             label1.Text="ODIN";
  43.         }
  44.  
  45.         void Button3Click(object sender, EventArgs e)
  46.         {
  47.             label2.Text="DVA!!!";
  48.         }
  49.  
  50.         void Button5Click(object sender, EventArgs e)
  51.         {
  52.             label3.Text="SPARTA!!!!!!";
  53.         }
  54.  
  55.         void Button2Click(object sender, EventArgs e)
  56.         {
  57.             panel1.Visible=false;
  58.  
  59.             panel2.Visible=false;
  60.             panel3.Visible=false; 
  61.             groupBox1.Visible=false; 
  62.         }
  63.  
  64.         void Button4Click(object sender, EventArgs e)
  65.         {
  66.             panel2.Visible=false; 
  67.  
  68.             panel1.Visible=false;
  69.             panel3.Visible=false;
  70.             groupBox1.Visible=false; 
  71.         }
  72.  
  73.         void Button6Click(object sender, EventArgs e)
  74.         {
  75.             panel3.Visible=false; 
  76.  
  77.             panel1.Visible=false;
  78.             panel2.Visible=false;
  79.             groupBox1.Visible=false; 
  80.         }
  81.     }
  82. }
Sep 23 '09 #1
1 1958
tlhintoq
3,525 Recognized Expert Specialist
Tracking all the changes yourself in all those methods is a ton of work and way too easy to get confused. Not to mention a lot of work to modify if you add a fourth panel.

May I suggest you just react when any of the panels raise a .VisibleChanged event?

Expand|Select|Wrap|Line Numbers
  1.         void N1ToolStripMenuItemClick(object sender, EventArgs e)
  2.         {
  3.              panel1.Visible=true;
  4.                          // The rest happens automatically from the VisibleChanged event
  5.         }
  6.  
  7.  
  8.  
  9.  
  10. private void Panel1_VisibleChange(object sender, eventargs e)
  11. {
  12.    Panel2.Visible = Panel3.Visible = False;
  13. }
  14.  
  15. private void Panel2_VisibleChange(object sender, eventargs e)
  16. {
  17.    Panel1.Visible = Panel3.Visible = False;
  18. }
  19.  
  20. private void Panel3_VisibleChange(object sender, eventargs e)
  21. {
  22.    Panel1.Visible = Panel2.Visible = False;
  23. }
  24.  
  25.  
  26.  
Sep 23 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1517
by: PZ | last post by:
OSS 2005 The First International Conference on Open Source Systems Genova, July 11 - 15, 2005 CALL FOR PANELS http://oss2005.case.unibz.it Submissions of panels are solicited for the "First International Conference on Open Source Systems, OSS2005", to be held in Genova, Italy from the 11th to the 15th of July 2005.
0
1386
by: PZ | last post by:
OSS 2005 The First International Conference on Open Source Systems Genova, July 11 - 15, 2005 CALL FOR PANELS http://oss2005.case.unibz.it Submissions of panels are solicited for the "First International Conference on Open Source Systems, OSS2005", to be held in Genova, Italy from the 11th to the 15th of July 2005.
1
7667
by: pfnus | last post by:
Hi, I want to display different forms when the buttons are clicked and all the forms are having different controls on it. So instead of adding new windows forms to the project, i enlarged the form and used many panels on the same form, which i think is easier to manage. However, i am having problems. Should i need to put the panels on the same location on the design layout? i put the panels at different places and it doesn't get...
4
7119
by: Miguel Dias Moura | last post by:
Hello, i have 5 panels in an ASP.net / VB page. The panel 1 is visible the other 4 are NOT visible. I also have 5 images: image 1, image 2, ..., image5. When i click one of the images, image N, the panel N becomes visible and all the other invisible.
2
3599
by: JJ | last post by:
Hi, How can I lay one panel over the other? I want to switch back and forth between panels that overlap. If I do this and make one invisible can I still load controls with data if that particular panel is invisible? Thanks, JJ
2
2509
by: randy1200 | last post by:
I'm working in Visual Studio 2005 and C#. I have a WinForms application with two panels (left panel and right panel). I have a textbox on the left panel, and a button on the right panel. I'd like to have a button-press from the right panel call a function in the left panel, which might simply Console.Writeline(textBox1.Text); If I could get the instance of the PanelLeft class, I could simply say: ...
1
4779
by: Ben | last post by:
Hi We have a number of Panels on our windows form, we have controls inside and outside of the panels. I am having problems tabbing between controls, it appers to be when the controls are within panels: It will tab though the controls outside the panels and then, tab into the panels. I have also tried setting the tab index at design time.
0
972
by: Rob Meade | last post by:
Hi all, I have a page, where, because it had to all be in one page there are a multitude of panels, with the use of a handful of conditions and the ability to show/hide panels I am able to make this page look like the user is moving between many... Here's my problem... I started off by simply seting the visibility to true/false etc in each code
4
2590
by: Brybot | last post by:
I have a form that i've split up into multiple asp:panels, each panel has a number of validators which work correctly. At on the last panel, i want to commit the data collected to a database. I figured since all the panel data is still being sent through the postbacks, instead of using Sessions, or HttpContext, I could just take the values from the textboxes. This all works fine, except for security. I realized that I could inject...
0
8483
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8402
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8825
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8605
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7445
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4416
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2819
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.