Welcome, Guest
Username: Password: Remember me
Qui si parla italiano
  • Page:
  • 1

TOPIC:

Passaggio di items da una ListBox ad un'altra 27 Dec 2022 17:47 #24887

  • claudiocarletta
  • claudiocarletta's Avatar
  • Topic Author


  • Posts: 94
  • Salve a tutti,
    ho la necessità di passare alcuni elementi selezionati (nominativo e IdRecord) da una ListBox con selezione multipla ad un'altra ListBox adiacente alla prima tramite un metodo (pulsante o altro)

    Ho provato con questi due metodi che vi posto, ma con nessuno dei due sono riuscito a risolvere il problema
    METHOD Passa( )
        local nPos	as DWORD
        local nEle	as DWORD
        
        nEle := SELF:oDCListaDocenti:ItemCount
        FOR nPos := 1 TO nEle							// Fase di selezione
            SELF:oDCListaDocenti:CurrentItemNo := nPos
            if SELF:oDCListaDocenti:IsSelected(nPos)
                SELF:oDCListaScelti:AddItem(SELF:oDCListaDocenti:TextValue, 0, SELF:oDCListaDocenti:Value)
            endif
    	NEXT
        
        nPos := SELF:oDCListaDocenti:FirstSelected()	               // Fase di eliminazione
        do while nPos > 0
            SELF:oDCListaDocenti:DeleteItem(nPos)
    		nPos := SELF:oDCListaDocenti:FirstSelected()   
    	enddo
    RETURN NIL
        
    METHOD PassaOld( )
        local nPos	as DWORD
        nPos := SELF:oDCListaDocenti:FirstSelected()	                            // Fase di selezione
        do while nPos > 0
            SELF:oDCListaScelti:AddItem(SELF:oDCListaDocenti:TextValue, 0, SELF:oDCListaDocenti:Value)
    		nPos := SELF:oDCListaDocenti:NextSelected()   
    	enddo
        
        nPos := SELF:oDCListaDocenti:FirstSelected()	                           // Fase di eliminazione
        do while nPos > 0
            SELF:oDCListaDocenti:DeleteItem(nPos)
    		nPos := SELF:oDCListaDocenti:NextSelected()   
    	enddo
    RETURN NIL

    Cosa mi suggerite?
    Vi ricordo che adopero X# nel dialetto VO

    Grazie a tutti
    Claudio
    Attachments:

    Please Log in or Create an account to join the conversation.

    Last edit: by claudiocarletta.

    Passaggio di items da una ListBox ad un'altra 27 Dec 2022 21:17 #24890

    • ic2
    • ic2's Avatar


  • Posts: 1667
  • Hello Claudio,

    You don't write what doesn't work.

    My approach in general is like this. The function returns an array of the content of the passed column (as symbolic name, in my function I can add multiple columns) for selected elements:
    FUNCTION SelectedLVItems(oLVControl,sKol1)
    	nItems:=oLVControl:SelectedCount
    	IF nItems>0
    		oItem:=oLVControl:GetNextitem(LV_GNIBYITEM,,,,TRUE,,)	// 1st item
    		uZoek:= oItem:GetValue(sKol1)
                   AAdd(aValues,uZoek)
    		FOR ni:=2 TO nItems          			// next selected items, if any
    			oItem:=oLVControl:GetNextitem(LV_GNIBYITEM,,,,TRUE,oItem:ItemIndex)
    			uZoek:= oItem:GetValue(sKol1)
                           AAdd(aValues,uZoek)
                    NEXT
            ENDIF
    RETURN aValues

    Then (with some extra steps we added) I empty both Listviews first:
    IF SELF:oDCLV1:ItemCount>0
    		oDCLV1:DeleteAll()
    	ENDIF
    	IF SELF:oDCLV2:ItemCount>0
    		oDCLV2:DeleteAll()
    	ENDIF

    and finally we add the value retrieved from 1 LV for each line to the second:
    METHOD VulLVLine(cKol1 AS STRING,cKey AS STRING,oLV AS OBJECT) AS LOGIC PASCAL CLASS SelectReceivers
    //#s Add item cKol1 with key cKey to listview oLV
    LOCAL oItem AS ListViewItem
    	oItem := ListViewItem{}
    	oItem:SetValue(cKol1,#Kol1)
    	oItem:SetValue(cKey,#KEY)
    	oLV:AddItem(oItem)
    RETURN TRUE

    I realize it's done differently but I think you left some septs out and looking at this code you can hopefully solve it.

    Dick

    Please Log in or Create an account to join the conversation.

    Last edit: by ic2.

    Passaggio di items da una ListBox ad un'altra [Risolto] 28 Dec 2022 01:28 #24891

    • claudiocarletta
    • claudiocarletta's Avatar
    • Topic Author


  • Posts: 94
  • Alla fine era più facile di quanto pensassi :whistle: :whistle: :whistle:
    METHOD Passa( )
        local dItem	as DWORD
        
        dItem := SELF:oDCListaDocenti:FirstSelected()
        do while dItem > 0
            SELF:oDCListaDocenti:CurrentItemNo := dItem
            SELF:oDCListaScelti:AddItem(SELF:oDCListaDocenti:CurrentItem, 0, SELF:oDCListaDocenti:Value)
            SELF:oDCListaDocenti:DeleteItem(dItem)
    	dItem := SELF:oDCListaDocenti:FirstSelected()   
    	enddo
    RETURN NIL

    Buona notte a tutti :)

    Please Log in or Create an account to join the conversation.

    Last edit: by claudiocarletta. Reason: Aggiunta riga 6: SELF:oDCListaDocenti:CurrentItemNo := dItem
    • Page:
    • 1
    Moderators: wriedmann