473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

panels interfere with each other

EntryTeam
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 1948
tlhintoq
3,525 Expert 2GB
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
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...
0
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...
1
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...
4
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,...
2
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...
2
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...
1
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...
0
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...
4
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.