Solved

Access the panel on which a clicked button resides

Posted on 2004-04-01
3
248 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

789 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