ListSelection

説明

一覧コントロール内の強調表示されたレコードのデータベース ID を戻します。

注: この関数は COM 専用です。Perl では使用できません。Rational ClearQuest Web インターフェイス内では使用できません。Rational® ClearQuest® Web の場合は回避策として、Entity オブジェクトFireNamedHook メソッドを使用できます。

ボタン クリック イベント (つまり、AD_BUTTON_CLICK イベント タイプ) の応答としてこのプロパティを使用すると、親/子リスト ボックスで選択された値を検出できます。このメソッドは、参照されたレコード タイプのプライマリ キーを戻します。

選択リストを取得するには、アイテムを選択できるようにするリスト コントロール (親子コントロールなど) にボタンを関連付ける必要があります。また、一覧タイプ、[その他] を選択する必要もあります。その後、ボタンをクリックすると、戻された値が参照されたレコードのキーとなります (複数パーツ キーの各部分は、スペースで区切られています)。

構文

VBScript

eventObject.ListSelection 
識別子
説明
eventObject
EventObject のインスタンス。
戻り値
単一文字列値 (または、選択されていない場合は空の配列) を含む Variant 配列が戻されます。戻された値には、参照されたレコードのキーが含まれています (複数パーツ キーの各部は、スペースで区切られています)。

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

フィードバック