Solved

Access the panel on which a clicked button resides

Posted on 2004-04-01
3
222 Views
Last Modified: 2010-04-15
Is it possible to replace this

private void buttonClose_Click(object sender, System.EventArgs e)
{
      this.panelPageEdit.Enabled = false;
      this.panelPageEdit.Visible = false;
      this.panelMainMenu.Enabled = true;
      this.panelMainMenu.Visible = true;
}

with a function that will disable and make invisible any panel depending on which panel the button clicked resides on? In other words I want to access the panel in which 'sender' is on. panelMainMenu will always be the panel I want to enable and make visible so that can stay the same.

Thanks.
0
Comment
Question by:wjdashwood
3 Comments
 
LVL 12

Assisted Solution

by:dfiala13
dfiala13 earned 230 total points
ID: 10731873
private void buttonClose_Click(object sender, System.EventArgs e)
{
   Button btn = (Button)sender;
   Panel p = (Panel)btn.Parent;

     p.Enabled = false;
     p.Visible = false;
     this.panelMainMenu.Enabled = true;
     this.panelMainMenu.Visible = true;



}
0
 
LVL 5

Accepted Solution

by:
AdrianJMartin earned 170 total points
ID: 10731896
private void buttonClose_Click(object sender, System.EventArgs e)
{
      Button b = (Button)sender;
      b.Parent.Visible = false ;
}
0
 

Author Comment

by:wjdashwood
ID: 10731898
Top dorris!

Cheers.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

757 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now