Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Custom Control and events

1 view
Skip to first unread message

Patrick M. Gahan

unread,
Sep 9, 2002, 4:18:59 AM9/9/02
to
I have a custom control which I've created and added a picturebox control in
it.
This picturebox changes the picture as you pass over it or click on it.
I want to send clicks on the picturebox to the form, so when I add my
control
to any form I have, I can receive the mouseUp event as you normally do with
a
regular button. I get to send messages from the picturebox to my custom
button's form, but can't get to pass it to the underlying form.

Does anyone know how to do this?

Thanks,
Patrick.

Nicholas Paldino [.NET/C# MVP]

unread,
Sep 9, 2002, 8:40:40 AM9/9/02
to
Patrick,

If I understand you correctly, what you want to do is expose events.
What you have to do is first define the event handler for your event (what
form the event handler should have anyways), through a delegate. Once you
have this, you can just declare an event of the delegate type. You can do
something like this:

public delegate MyEventHandler(object sender, EventArgs e);

public event MyEventHandler MyEvent;

Then, when you want to fire the event, you do it like this:

// Check to see if the anyone hooked up for the event.
if (MyEvent != null)
// Fire the event.
MyEvent(this, new EventArgs());

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- nicholas...@exisconsulting.com

"Patrick M. Gahan" <patrick...@hotmail.com> wrote in message
news:OPmD#l9VCHA.1496@tkmsftngp11...

Patrick M. Gahan

unread,
Sep 9, 2002, 9:01:14 AM9/9/02
to
What I did is just to call the form's OnMouseUp function with the same
arguments passed by the picturebox.

private void pctboxImage_MouseUp(object sender,
System.Windows.Forms.MouseEventArgs e)

{

pctboxImage.Image = imglstButtons.Images[0];

this.OnMouseUp(e);

}

This I do it after changing my image to the one I like, for an instance, the
button clicked.

This way I constructed a customizabel button with your own graphics.

If anyone needs this type of custom control, just mail me.

Thanks,

Patrick.


"Nicholas Paldino [.NET/C# MVP]" <nicholas...@exisconsulting.com> wrote
in message news:uOzZ06$VCHA.4012@tkmsftngp08...

0 new messages