Event problem

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

    #1

    Event problem

    Hi all,

    Can anyone tell me what is this?

    C:\Documents and Settings\Admini strator\My Documents\Visua l Studio
    Projects\Editab leTest\Editable Test\GridPanel. cs(40):
    'System.Windows .Forms.Control. OnMouseMove(Sys tem.Windows.For ms.MouseEventAr g
    s)' denotes a 'method' which is not valid in the given context

    Thanks

    Durand


  • Durand

    #2
    Re: Event problem

    My code:

    private void inicializaCompo nentes()

    {

    // Inicializa

    this.OnMouseMov e += new
    System.Windows. Forms.MouseEven tHandler(this.m ouseMove);

    }

    private void mouseMove(objec t sender, System.Windows. Forms.MouseEven tArgs e)

    {

    bool faixa = false;

    int posX = 0;

    if(e.Y >= 1 && e.Y <= 14)

    faixa = true;

    for(int i = 0; i <= colunas.GetUppe rBound(0); i++)

    {

    if(e.X >= posX && e.X <= posX + colunas[i].Largura)

    colunas[i].MouseOver = faixa;

    colunas[i].MouseOver = false;

    posX = colunas[i].Largura + 1;

    }

    }



    "Cole Breidenbach" <cybreid2000@ya hoo.com> wrote in message
    news:02f001c398 0f$10e4fe40$a40 1280a@phx.gbl.. .[color=blue]
    >
    > Does the event wire up code designate a method within the
    > control container? Sounds like the method assigned to the
    > event is not available because of a scope issue.[color=green]
    > >-----Original Message-----
    > >Hi all,
    > >
    > >Can anyone tell me what is this?
    > >
    > >C:\Documents and Settings\Admini strator\My[/color]
    > Documents\Visua l Studio[color=green]
    > >Projects\Edita bleTest\Editabl eTest\GridPanel .cs(40):
    > >'System.Window s.Forms.Control .OnMouseMove[/color]
    > (System.Windows .Forms.MouseEve ntArg[color=green]
    > >s)' denotes a 'method' which is not valid in the given[/color]
    > context[color=green]
    > >
    > >Thanks
    > >
    > >Durand
    > >
    > >
    > >.
    > >[/color][/color]


    Comment

    • Cole Breidenbach

      #3
      Re: Event problem

      Okay, spotted the problem. Change the event handler code
      to read the following:

      this.MouseMove += new
      System.Windows. Forms.MouseEven tHandler(this.m ouseMove)

      You are trying to assign an event handler to a protected
      method of the form. You need to assign the event handler
      to the Form MouseMove event.

      Hope this helps.
      [color=blue]
      >-----Original Message-----
      >My code:
      >
      >private void inicializaCompo nentes()
      >
      >{
      >
      >// Inicializa
      >
      >this.OnMouseMo ve += new
      >System.Windows .Forms.MouseEve ntHandler(this. mouseMove);
      >
      >}
      >
      >private void mouseMove(objec t sender,[/color]
      System.Windows. Forms.MouseEven tArgs e)[color=blue]
      >
      >{
      >
      >bool faixa = false;
      >
      >int posX = 0;
      >
      >if(e.Y >= 1 && e.Y <= 14)
      >
      >faixa = true;
      >
      >for(int i = 0; i <= colunas.GetUppe rBound(0); i++)
      >
      >{
      >
      >if(e.X >= posX && e.X <= posX + colunas[i].Largura)
      >
      >colunas[i].MouseOver = faixa;
      >
      >colunas[i].MouseOver = false;
      >
      >posX = colunas[i].Largura + 1;
      >
      >}
      >
      >}
      >
      >
      >
      >"Cole Breidenbach" <cybreid2000@ya hoo.com> wrote in[/color]
      message[color=blue]
      >news:02f001c39 80f$10e4fe40$a4 01280a@phx.gbl. ..[color=green]
      >>
      >> Does the event wire up code designate a method within[/color][/color]
      the[color=blue][color=green]
      >> control container? Sounds like the method assigned to[/color][/color]
      the[color=blue][color=green]
      >> event is not available because of a scope issue.[color=darkred]
      >> >-----Original Message-----
      >> >Hi all,
      >> >
      >> >Can anyone tell me what is this?
      >> >
      >> >C:\Documents and Settings\Admini strator\My[/color]
      >> Documents\Visua l Studio[color=darkred]
      >> >Projects\Edita bleTest\Editabl eTest\GridPanel .cs(40):
      >> >'System.Window s.Forms.Control .OnMouseMove[/color]
      >> (System.Windows .Forms.MouseEve ntArg[color=darkred]
      >> >s)' denotes a 'method' which is not valid in the given[/color]
      >> context[color=darkred]
      >> >
      >> >Thanks
      >> >
      >> >Durand
      >> >
      >> >
      >> >.
      >> >[/color][/color]
      >
      >
      >.
      >[/color]

      Comment

      • Durand

        #4
        Re: Event problem

        Work's fine, thanks!

        "Cole Breidenbach" <cybreid2000@ya hoo.com> wrote in message
        news:05de01c398 1d$072cdcc0$a10 1280a@phx.gbl.. .[color=blue]
        > Okay, spotted the problem. Change the event handler code
        > to read the following:
        >
        > this.MouseMove += new
        > System.Windows. Forms.MouseEven tHandler(this.m ouseMove)
        >
        > You are trying to assign an event handler to a protected
        > method of the form. You need to assign the event handler
        > to the Form MouseMove event.
        >
        > Hope this helps.
        >[color=green]
        > >-----Original Message-----
        > >My code:
        > >
        > >private void inicializaCompo nentes()
        > >
        > >{
        > >
        > >// Inicializa
        > >
        > >this.OnMouseMo ve += new
        > >System.Windows .Forms.MouseEve ntHandler(this. mouseMove);
        > >
        > >}
        > >
        > >private void mouseMove(objec t sender,[/color]
        > System.Windows. Forms.MouseEven tArgs e)[color=green]
        > >
        > >{
        > >
        > >bool faixa = false;
        > >
        > >int posX = 0;
        > >
        > >if(e.Y >= 1 && e.Y <= 14)
        > >
        > >faixa = true;
        > >
        > >for(int i = 0; i <= colunas.GetUppe rBound(0); i++)
        > >
        > >{
        > >
        > >if(e.X >= posX && e.X <= posX + colunas[i].Largura)
        > >
        > >colunas[i].MouseOver = faixa;
        > >
        > >colunas[i].MouseOver = false;
        > >
        > >posX = colunas[i].Largura + 1;
        > >
        > >}
        > >
        > >}
        > >
        > >
        > >
        > >"Cole Breidenbach" <cybreid2000@ya hoo.com> wrote in[/color]
        > message[color=green]
        > >news:02f001c39 80f$10e4fe40$a4 01280a@phx.gbl. ..[color=darkred]
        > >>
        > >> Does the event wire up code designate a method within[/color][/color]
        > the[color=green][color=darkred]
        > >> control container? Sounds like the method assigned to[/color][/color]
        > the[color=green][color=darkred]
        > >> event is not available because of a scope issue.
        > >> >-----Original Message-----
        > >> >Hi all,
        > >> >
        > >> >Can anyone tell me what is this?
        > >> >
        > >> >C:\Documents and Settings\Admini strator\My
        > >> Documents\Visua l Studio
        > >> >Projects\Edita bleTest\Editabl eTest\GridPanel .cs(40):
        > >> >'System.Window s.Forms.Control .OnMouseMove
        > >> (System.Windows .Forms.MouseEve ntArg
        > >> >s)' denotes a 'method' which is not valid in the given
        > >> context
        > >> >
        > >> >Thanks
        > >> >
        > >> >Durand
        > >> >
        > >> >
        > >> >.
        > >> >[/color]
        > >
        > >
        > >.
        > >[/color][/color]


        Comment

        • Cole Breidenbach

          #5
          Event problem


          Does the event wire up code designate a method within the
          control container? Sounds like the method assigned to the
          event is not available because of a scope issue.[color=blue]
          >-----Original Message-----
          >Hi all,
          >
          >Can anyone tell me what is this?
          >
          >C:\Documents and Settings\Admini strator\My[/color]
          Documents\Visua l Studio[color=blue]
          >Projects\Edita bleTest\Editabl eTest\GridPanel .cs(40):
          >'System.Window s.Forms.Control .OnMouseMove[/color]
          (System.Windows .Forms.MouseEve ntArg[color=blue]
          >s)' denotes a 'method' which is not valid in the given[/color]
          context[color=blue]
          >
          >Thanks
          >
          >Durand
          >
          >
          >.
          >[/color]

          Comment

          Working...