Raise Event

  • Thread starter Thread starter Mauricio Rendon
  • Start date Start date
M

Mauricio Rendon

Hi,

If I have a Label in a Form and need to raise the MouseUp
event on the label to the Form ( Parent Control ), What
must I do ?

Thanks !!!
 
Hi,

It's not completely clear what do you actually want to do...
If you use some custom label, the System.Windows.Forms.Label class has a
protected OnMouseUp method you can call to raise the event. So you could
create an inherited control, expose a public method called something like
ImitateClick that would in turn call the protected OnMouseUp method, raising
the MouseUp event.

Then provided that the form will have been supplied an event handler by the
time the event is raised, this handler will be invoked just like you have
really clicked on the label.
 
Event procedures are just method calls like any other, so within the Label's
MouseUp event code a call to the Form's MouseUp event.

For example

private void label1_MouseUp(object sender,
System.Windows.Forms.MouseEventArgs e)
{
this.OnMouseUp(e);
}
 
Back
Top