Raise Event

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mauricio Rendon

    #1

    Raise Event

    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 !!!

  • Dmitriy Lapshin [C# / .NET MVP]

    #2
    Re: Raise Event

    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.

    --
    Dmitriy Lapshin [C# / .NET MVP]
    X-Unity Test Studio

    Bring the power of unit testing to VS .NET IDE

    "Mauricio Rendon" <mrendon78@hotm ail.com> wrote in message
    news:147201c388 38$c9fea200$a00 1280a@phx.gbl.. .[color=blue]
    > 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 !!!
    >[/color]

    Comment

    • Neil McKechnie

      #3
      Re: Raise Event

      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.MouseEven tArgs e)
      {
      this.OnMouseUp( e);
      }

      --
      ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~
      Neil McKechnie
      Microlink Associates Ltd
      NeilM@Microlink Associates.couk
      "Mauricio Rendon" <mrendon78@hotm ail.com> wrote in message
      news:147201c388 38$c9fea200$a00 1280a@phx.gbl.. .[color=blue]
      > 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 !!!
      >[/color]


      Comment

      Working...