ListSelection

Descrizione

Restituisce l'ID del database di un record evidenziato all'interno del controllo listview.

Nota: questa funzione è solo per COM. Non è disponibile per Perl, ed è disponibile solo nel client ClearQuest per Windows.

È possibile utilizzare questa proprietà in risposta ad un evento di selezione di pulsante (cioè, il tipo di evento AD_BUTTON_CLICK) per individuare quale valore viene selezionato in una casella di riepilogo padre/figlio. I metodi restituiscono la chiave primaria del tipo di record di riferimento.

Per ottenere una selezione elenco, è necessario associare il pulsante al controllo elenco (come un controllo figlio del padre) da cui si desidera poter selezionare un elemento. È inoltre necessario selezionare Vista elenco tipo Altro. Poi, quando si preme il pulsante, il valore restituito è la chiave del record di riferimento (parti di chiavi a più parti sono separate da spazi).

Sintassi

VBScript

eventObject.ListSelection 
Identificativo
Descrizione
eventObject
Un'istanza di EventObject.
Valore di ritorno
Restituisce un array Variant contenente una singola stringa (o un array vuoto se non viene effettuata alcuna selezione). Il valore restituito contiene la chiave del record di riferimento (parti di chiavi a più parti sono separate da spazi).

Esempi

VBScript

' The following script is invoked  when a user presses a button named "Select" 
' that is associated with a ListView control and performs an action of type
' "Other" (on the extended properties tab)):

   Function Defect_Cust_Sel(param)

      ' param As Variant

      Dim ListSel, Sel

      On Error Resume Next

      ListSel = param.ListSelection

      Sel = ListSel(0)

      SetFieldValue "Customer", Sel

   End Function



' The following example checks for event type, session type, and whether or
' not something is selected:

   Function MyRecordHook(param)

    ' param As Variant

     ' record type name isMyRecord

      Dim ListSel

      Dim Item

      ' Check if it is an event which you can have a selection for

      if param.eventtype = AD_BUTTON_CLICK then

      ' Make sure you aren't on the web since ListSelection doesn't work 
there

         if not GetSession.HasValue("_CQ_WEB_SESSION") then

            ' OK we're not on the web. Now check to see if anything is 
selected

            ListSel = param.ListSelection

            if ubound(ListSel) < lbound(ListSel) then

               ' Nothing is selected

            else

               Item = ListSel(0)

               ' ListSel is an array of strings with one element when 
               ' something is selected
                ' and no elements when nothing is selected

               ' Put your code here to do what you need to do

               msgbox "Selected item was:" & Item

            end if

         else

            ' Web interface, ListSelection API call doesn't work here

         end if

      else

         ' Its not a button click event, listselection only works with
         ' button click events

      end if

   End Function 

Feedback