Programación General > Visual Basic 6.0 e inferiores

 Cancelar Evento Selectedindexchanged

(1/2) > >>

jenunez:
Aun no me manejo bien en este foro, perdón.

Tengo un listviewitem seleccionado en un listview que tengo que validar antes de cambiar de selección. La validación he de hacerla en evento SelectedIndexChanged cuando se ha seleccionado otr elemento. El problema es que si la validación falla, ¿como puedo cancelar la selección?

RadicalEd:
No te entendi y hola a ti :blink:

RadicalEd:
Primero que todo no es un evento es una propiedad, ademas la propiedad que describes no existe, solamente la SelectedItem, en algo debes estar enrredado, por que no colocas el codigo y asi se te revisa.

PD. no modifiques los posts por que es poco probable que se vuelvan a ver, lo mejor es colocar un nuevo post dentro del hilo del mensaje

jenunez:
OK Entendido lo del post.
En cuanto a que no es un evento, discrepo bastante de ti...


--- Código: Text ---Handles ListView1.SelectedIndexChanged 
La idea es poder "parar" el cambio de Item seleccionado si no es correcta cierta condición


--- Código: Text ---If bCancelar Then Exit Sub  If ListView1.SelectedItems.Count > 0 Then    'Estamos deseleccionando el elto de la vista    If ListView1.SelectedItems(0).Index <> previous Then      Dim sError As String      If Not bValido(sError) Then        If MsgBox("Se han producido errores validando& Chr(13) & sError & Chr(13) & "¿Desea continuar?", MsgBoxStyle.YesNo + MsgBoxStyle.Exclamation, "Validación") <> MsgBoxResult.Yes Then¡'Cancelamos. No procesamos nueva selección                bCancelar = True  ListView1.SelectedItems(0).Selected = False  ListView1.Items(previous).Selected = True        End If      End If    End If  Else    Exit Sub End If 

RadicalEd:
Y te lo sigo repitiendo eso no es un evento es una propiedad, los eventos son aquellos a los que tu accedes cuando le das una click a un control, por ejemplo el evento click que tienen casi todos los controles, aqui te dejo los unicos eventos que le conozco al listview

--- Código: Text --- Private Sub ListView1_AfterLabelEdit(Cancel As Integer, NewString As String)Private Sub ListView1_BeforeLabelEdit(Cancel As Integer)Private Sub ListView1_Click()Private Sub ListView1_DblClick()Private Sub ListView1_DragDrop(Source As Control, x As Single, y As Single)Private Sub ListView1_DragOver(Source As Control, x As Single, y As Single, State As Integer)Private Sub ListView1_GotFocus()Private Sub ListView1_ItemClick(ByVal Item As ComctlLib.ListItem)Private Sub ListView1_KeyDown(KeyCode As Integer, Shift As Integer)Private Sub ListView1_KeyPress(KeyAscii As Integer)Private Sub ListView1_KeyUp(KeyCode As Integer, Shift As Integer)Private Sub ListView1_LostFocus()Private Sub ListView1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)Private Sub ListView1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)Private Sub ListView1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)Private Sub ListView1_OLECompleteDrag(Effect As Long)Private Sub ListView1_OLEDragDrop(Data As ComctlLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)Private Sub ListView1_OLEDragOver(Data As ComctlLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single, State As Integer)Private Sub ListView1_OLEGiveFeedback(Effect As Long, DefaultCursors As Boolean)Private Sub ListView1_OLESetData(Data As ComctlLib.DataObject, DataFormat As Integer)Private Sub ListView1_OLEStartDrag(Data As ComctlLib.DataObject, AllowedEffects As Long)  

Navegación

[0] Índice de Mensajes

[#] Página Siguiente

Ir a la versión completa