K S Reddi Prasad

K S Reddi Prasad

  • NA
  • 28
  • 74.7k

How to put multiple events code in a single event

Apr 1 2011 7:21 AM

Hi all,
 I am coding an c#.net application, where i have multiple  events for multiple buttons. Now, I wanted to put all that code in a single event and i have to work as it was working previously. Can i use a switch case inside the Event???

Here  is the sample code of multiple events:

  if (button.SelectSingleNode("ButtonId").InnerText == "btnRefresh")
  rButton.Click += new EventHandler<RibbonControlEventArgs>(btnRefresh_Click);
  else if (button.SelectSingleNode("ButtonId").InnerText == "btnSaveToVGF")
  rButton.Click += new EventHandler<RibbonControlEventArgs>(btnSaveToVGF_Click);
  else if (button.SelectSingleNode("ButtonId").InnerText == "btnSubmit")
   rButton.Click += new EventHandler<RibbonControlEventArgs>(btnSubmit_Click);
 

  Now, I want to work on a single event and That event should handle all these events code. I mean all the code in btnRefresh_Click, btnSaveToVGF_Click, btnSubmit_Click into a single event button_click. so when i click this any button, this event should be handled and appropriate action should be taken using switch case.

  Any help would be greatly appreciated.

Thanks & Regards,
K.S.Reddi Prasad.

Answers (3)