Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 275
  • Last Modified:

Access the panel on which a clicked button resides

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
wjdashwood
Asked:
wjdashwood
2 Solutions
 
dfiala13Commented:
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
 
AdrianJMartinCommented:
private void buttonClose_Click(object sender, System.EventArgs e)
{
      Button b = (Button)sender;
      b.Parent.Visible = false ;
}
0
 
wjdashwoodAuthor Commented:
Top dorris!

Cheers.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now