2 Replies - 373 Views - Last Post: 21 November 2009 - 03:37 PM Rate Topic: -----

#1 Braindead  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 21-June 09

One method for several panels

Post icon  Posted 15 November 2009 - 11:48 AM

Hi :)

I have written the following code which creates several panels
on another panel. I add some properties.

Panel[] PNL = new Panel[10];
			for (i = 1; i < 10; i++)
			{
				PNL[i] = new Panel();
				PNL[i].Size = new Size(55, 60);
				PNL[i].BorderStyle = BorderStyle.FixedSingle;
				 panel1.Controls.Add(PNL[i]);
				}
			


But I need some help to write one onclick method for all
so that the onclick method know which panel is clicked.

Any hints or so would be helpful :^:

Is This A Good Question/Topic? 0
  • +

Replies To: One method for several panels

#2 Momerath  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1010
  • View blog
  • Posts: 2,444
  • Joined: 04-October 09

Re: One method for several panels

Posted 15 November 2009 - 12:14 PM

Just cast the sender object into a Panel:
public void PanelClick(object sender, EventArgs e) {
	Panel p = (Panel)sender;
}

Now you have the panel object that triggered the click event. From the name you can tell which one if you really need to, or you can just call the methods that the panel contains.
Was This Post Helpful? 0
  • +
  • -

#3 Braindead  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 21-June 09

Re: One method for several panels

Posted 21 November 2009 - 03:37 PM

:^: Thank you
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1