Events in User Control

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lalit Bhatia

    Events in User Control

    I am creating a Usercontrol, In my user control I have one datagrid.

    I want if user double clicks on datagrid, then double click of user control
    fire.
    how can we implement this?
    any suggestions?

    --
    Regards,
    Lalit Bhatia


  • Rodrigo Ferreira

    #2
    Re: Events in User Control



    private void dataGrid1_Doubl eClick(object sender, System.EventArg s e)

    {

    UserControl1_Do ubleClick(sende r,e);

    }

    private void UserControl1_Do ubleClick(objec t sender, System.EventArg s e)

    {

    MessageBox.Show ("Hello");

    }

    "Lalit Bhatia" <xyz@abc.com> wrote in message news:uS3IRZoaFH A.2900@TK2MSFTN GP15.phx.gbl...[color=blue]
    >
    > I am creating a Usercontrol, In my user control I have one datagrid.
    >
    > I want if user double clicks on datagrid, then double click of user control
    > fire.
    > how can we implement this?
    > any suggestions?
    >
    > --
    > Regards,
    > Lalit Bhatia
    >
    >
    >[/color]

    Comment

    • Peter van der Goes

      #3
      Re: Events in User Control


      "Lalit Bhatia" <xyz@abc.com> wrote in message
      news:uS3IRZoaFH A.2900@TK2MSFTN GP15.phx.gbl...[color=blue]
      >I am creating a Usercontrol, In my user control I have one datagrid.
      >
      > I want if user double clicks on datagrid, then double click of user
      > control
      > fire.
      > how can we implement this?
      > any suggestions?
      >
      > --
      > Regards,
      > Lalit Bhatia
      >
      >[/color]
      Have you created the event for your user control? In that event handler, you
      need to raise the event for your datagrid.
      What follows is VB-like pseudocode, but it illustrates the principle:

      ----IN THE USERCONTROL CLASS (pseudo-code)
      Public Event CtlClick(ByVal sender As Object, ByVal e As
      System.EventArg s)

      Private Sub UserControl_Cli ck(ByVal sender As System.Object, ...
      RaiseEvent CtlClick(Me, New System.EventArg s)
      End Sub


      Private Sub {labelname}_Cli ck (ByVal sender As System.Object, ...
      RaiseEvent CtlClick(Me, New System.EventArg s)
      End Sub


      ----IN THE FORM/CLASS THAT CONSUMES USERCONTROL (pseudo-code)
      Private Sub UserControl1_Ct lClick (ByVal sender As Object, ByVal e As
      _
      System.EventArg s) Handles UserControl1.Cl ick
      'Code to handle CtlClick event
      End Sub


      Sorry, couldn't find a C# code example this morning.


      --
      Peter [MVP Visual Developer]
      Jack of all trades, master of none.


      Comment

      Working...