Solved

Access the panel on which a clicked button resides

Posted on 2004-04-01
3
255 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

680 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