evento que se repite

25/01/2005 - 19:32 por Imac_Man | Informe spam
saludos amigos

Porque pasara que a veces los eventos se repiten aunque no tengan que
hacerlo para nadase que no es un caso que solamente me pase a mi incluso
e visto codigo de ejemplo en internet sobre uso de variables para controlar
este problema anexo un ejmplo que he visto con esta clase de solucion

Reinout (IS/IT--Manageme) Dec 30, 2004
Problem was solved as soon as I added this code to all datagrids on
the page. Don't ask me why, but it works now :)

I'll paste the whole sub for those interested :

Private Sub myDatagrid_Leave(ByVal sender As Object, ByVal e As
System.EventArgs) Handles myDatagrid.Leave
If controlDatagrid Then
myDatagrid.EndEdit(Nothing, myDatagrid.CurrentRowIndex,
False)
myDatagrid.BindingContext(myDatagrid.DataSource,
myDatagrid.DataMember).EndCurrentEdit()
Call UpdateDatabase()
controlDatagrid = False
Else
controlDatagrid = True
End If
End Sub

I insert a boolean because he tends to go through the sub twice, first
trying to leave the datagrid, but the update sub keeps the focus on the
datagrid, the second time the event is called I don't want to look for
possible changes, so I added the "controlDatagrid = false" to the first
part, I put it back on true in case I enter and leave the datagrid again.
 

Leer las respuestas

#1 Misael Monterroca
25/01/2005 - 19:59 | Informe spam
Existen mètodos que se generan en cascada, por ejemplo, si en el grid
que comentas existe un textbox, primero se generara el evento leave del
textbox y posteriormente el leave del Grid, para determinar si el evento
realmente se està ejecutando doble, primero se deberia de analizar el
comportamiento que se està realizando, para poder identificar el por què
el control està generando dos veces el mismo evento.

Preguntas similares