CrAzY hOuSe
Locos por la programación
Seleccionar y Eliminar todos los elementos de un ListBox
.net

Syndication

Insertar un ListBox y dos Botón en un nuevo proyecto. Poner la propiedad MultiSelect del ListBox a "1 - Simple" y escriba el siguiente código:

Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
             ByVal wParam As Long, ByVal lParam As Long) As Long

Private Sub Form_Load()
    List1.AddItem "Texto 1"
    List1.AddItem "Texto 2"
    List1.AddItem "Texto 3"
    List1.AddItem "Texto 4"
    List1.AddItem "Texto 5"
    List1.AddItem "Texto 6"
    List1.AddItem "Texto 7"
End Sub

Private Sub Command1_Click()
    'Seleccion de todo el contenido
    Dim Resp As Long
    Resp = SendMessageLong(List1.hwnd, &H185&, True, -1)
End Sub

Private Sub Command2_Click()
    'Eliminacion de todos los elementos seleccionados
    Dim Resp As Long
    Resp = SendMessageLong(List1.hwnd, &H185&, False, -1)
End Sub

Posted dom, dic 26 1999 19:40 by Maverick
Filed under: ,

Add a Comment

(optional)  
(optional)
(required)  
Remember Me?
MavericK
Powered by Community Server (Non-Commercial Edition), by Telligent Systems