List Info

Thread: C-Sharp (C#) Group: Handling events for Array controls with a single event handler




C-Sharp (C#) Group: Handling events for Array controls with a single event handler
user name
2006-01-10 08:25:42
I would like to uses a Control Array (class) Event in a form
to call
another function in the form.

I have built an Array of Controls using the below link as a
ref:

msdn.microsoft.com/library/default.asp?url=/library/en-us/dv
_vstechart/html/vbtchcreatingcontrolarraysinvisualbasicnetvi
sualcnet.asp

I have been trying to get this code to work:

AddControlLinkLabel = myControl;  (in the form class)

myControl = new AddControlLinkLabel(this); (in the form
constructor)

What I would like to do is right from from Microsoft
"Handling events
for multiple controls with a single event handler, and
retrieving and
using the index in those events, as shown in this
example:"

private void myControl_Click(System.Object sender,
System.EventArgs e)
   {
      Messagebox.Show("You have clicked MyControl
number " +
         myControl.Index);
   }

But I have put the above code in the form, and have been
calling my
class (AddControlLinkLabel) to build the Array of controls
but Im not
having any luck with the above event handler.

 I tried using the "Common Event Handler" in the
class but can not get
back to the Form from the class.

Does anyone have any ideas? Thank You For the Help!

C-Sharp (C#) Group: Re: Handling events for Array controls with a single event handler
user name
2006-01-10 09:21:15

I figured it out, I forgot to put in the following code
while builting
the Array.

myControl[index].Click += new
System.EventHandler(myControl_Click);

thanks!

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )