Event problem

  • Thread starter Thread starter Durand
  • Start date Start date
D

Durand

Hi all,

Can anyone tell me what is this?

C:\Documents and Settings\Administrator\My Documents\Visual Studio
Projects\EditableTest\EditableTest\GridPanel.cs(40):
'System.Windows.Forms.Control.OnMouseMove(System.Windows.Forms.MouseEventArg
s)' denotes a 'method' which is not valid in the given context

Thanks

Durand
 
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.
 
My code:

private void inicializaComponentes()

{

// Inicializa

this.OnMouseMove += new
System.Windows.Forms.MouseEventHandler(this.mouseMove);

}

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

{

bool faixa = false;

int posX = 0;

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

faixa = true;

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

{

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

colunas.MouseOver = faixa;

colunas.MouseOver = false;

posX = colunas.Largura + 1;

}

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

this.MouseMove += new
System.Windows.Forms.MouseEventHandler(this.mouseMove)

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.
-----Original Message-----
My code:

private void inicializaComponentes()

{

// Inicializa

this.OnMouseMove += new
System.Windows.Forms.MouseEventHandler(this.mouseMove);

}

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

bool faixa = false;

int posX = 0;

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

faixa = true;

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

{

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

colunas.MouseOver = faixa;

colunas.MouseOver = false;

posX = colunas.Largura + 1;

}

}



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.


.
 
Work's fine, thanks!

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

this.MouseMove += new
System.Windows.Forms.MouseEventHandler(this.mouseMove)

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.
-----Original Message-----
My code:

private void inicializaComponentes()

{

// Inicializa

this.OnMouseMove += new
System.Windows.Forms.MouseEventHandler(this.mouseMove);

}

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

bool faixa = false;

int posX = 0;

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

faixa = true;

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

{

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

colunas.MouseOver = faixa;

colunas.MouseOver = false;

posX = colunas.Largura + 1;

}

}



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.
-----Original Message-----
Hi all,

Can anyone tell me what is this?

C:\Documents and Settings\Administrator\My
Documents\Visual Studio
Projects\EditableTest\EditableTest\GridPanel.cs(40):
'System.Windows.Forms.Control.OnMouseMove
(System.Windows.Forms.MouseEventArg
s)' denotes a 'method' which is not valid in the given
context

Thanks

Durand


.


.
 
Back
Top