Influnce a listbox in a grid

Hi all,
I try to influence a custom listbox in a grid maintaining different values in the different lines of the grid.
I implement the code in the method IF_CRM_BSP_MODEL_ACCESS_IL~FILL_DROPDOWN_LISTBOX, in debug mode I display the correct value in each line but when I display the BSP in every line appear the value that I first modified.
Have you any idea?
Thank you
Giulio

Hi,
this is the code:
METHOD if_crm_bsp_model_access_il~fill_dropdown_listbox.
Call superclass
  CALL METHOD super->if_crm_bsp_model_access_il~fill_dropdown_listbox
    EXPORTING
      iv_object_key            = iv_object_key
      iv_screen_structure_name = iv_screen_structure_name
      iv_all_values            = iv_all_values
      it_screen_structure      = it_screen_structure
    IMPORTING
      et_field_catalog         = et_field_catalog
    CHANGING
      ct_dropdownlb_data       = ct_dropdownlb_data.
    FIELD-SYMBOLS: <fs_ddlb>             TYPE crmt_dropdownlistbox_data,
                   <lt_responsarea_data> TYPE shsvaltab.
    DATA: l_shsvalstr TYPE shsvalstr.
    DATA: l_tabix TYPE sy-tabix.
    LOOP AT ct_dropdownlb_data ASSIGNING <fs_ddlb>.
      IF <fs_ddlb>-fieldname = 'TEST'.
EX: No Line
        IF itm_type IS INITIAL.
          FREE <fs_ddlb>-data.
        ENDIF.
EX: First line in the Grid
        IF itm_type EQ 'LINE_ONE'.
          ASSIGN <fs_ddlb>-data->* TO <lt_responsarea_data>.
          LOOP AT <lt_responsarea_data> INTO l_shsvalstr.
            MOVE sy-tabix TO l_tabix.
            IF NOT l_shsvalstr-key IS INITIAL.
      Delete entry from listbox, for field TEST
              DELETE <lt_responsarea_data> INDEX l_tabix.
            ENDIF.
          ENDLOOP.
          MOVE: '001'    TO l_shsvalstr-key,
                'TEST001' TO l_shsvalstr-value.
          APPEND l_shsvalstr TO <lt_responsarea_data>.
        ENDIF.
EX: Second line in the Grid
        IF itm_type EQ 'LINE_TWO'.
          ASSIGN <fs_ddlb>-data->* TO lt_responsarea_data>.
          LOOP AT <lt_responsarea_data> INTO l_shsvalstr.
            MOVE sy-tabix TO l_tabix.
            IF NOT l_shsvalstr-key IS INITIAL.
      Delete entry from listbox, for field TEST
              DELETE <lt_responsarea_data> INDEX l_tabix.
            ENDIF.
          ENDLOOP.
          MOVE: '002'     TO l_shsvalstr-key,
                'TEST002' TO l_shsvalstr-value.
          APPEND l_shsvalstr TO <lt_responsarea_data>.
        ENDIF.
      ENDIF.
    ENDLOOP.
ENDMETHOD.
I display only the first entry 001 in both lines, but in debug mode when I insert the second line I look into the internal table ct_dropdownlb_data the second entry.
Thank you for your support
Giulio

Similar Messages

  • Listbox in alv grid output -Possible?

    Can List box or drop down box can be placed in ALV Grid(Using FM) Ouput for a field .
    please clarify

    Check thse two examples.
    BCALV_EDIT_06
    BCALV_EDIT_07
    check the steps..
    Re: Dopdown Listbox in ALV Grid OO Concept
    and also Check this code.
    also check the below threads...
    List Box in ALV Grid
    In ALV  list box
    Dropdown list  in ALV
    Hope it will solve your problem..
    Thanks & Regards
    ilesh 24x7
    REPORT  ZTEST1234_ALV_TOP    MESSAGE-ID ZZ                           .
    DATA: G_GRID TYPE REF TO CL_GUI_ALV_GRID.
    DATA: L_VALID TYPE C,
          V_FLAG,
          V_DATA_CHANGE,
          V_ROW TYPE LVC_S_ROW,
          V_COLUMN TYPE LVC_S_COL,
          V_ROW_NUM TYPE LVC_S_ROID.
    DATA: IT_ROW_NO TYPE LVC_T_ROID,
          X_ROW_NO TYPE LVC_S_ROID.
    DATA:BEGIN OF  ITAB OCCURS 0,
         VBELN LIKE LIKP-VBELN,
         POSNR LIKE LIPS-POSNR,
         CELLCOLOR TYPE LVC_T_SCOL, "required for color
         DROP(10),
         END OF ITAB.
    "The Below Definitions Must.....
    DATA:
    * Reference to document
           DG_DYNDOC_ID       TYPE REF TO CL_DD_DOCUMENT,
    * Reference to split container
           DG_SPLITTER          TYPE REF TO CL_GUI_SPLITTER_CONTAINER,
    * Reference to grid container
           DG_PARENT_GRID     TYPE REF TO CL_GUI_CONTAINER,
    * Reference to html container
           DG_HTML_CNTRL        TYPE REF TO CL_GUI_HTML_VIEWER,
    * Reference to html container
           DG_PARENT_HTML     TYPE REF TO CL_GUI_CONTAINER.
    "up to here
    *       CLASS lcl_event_handler DEFINITION
    CLASS LCL_EVENT_HANDLER DEFINITION .
      PUBLIC SECTION .
        METHODS:
    **Hot spot Handler
        HANDLE_HOTSPOT_CLICK FOR EVENT HOTSPOT_CLICK OF CL_GUI_ALV_GRID
                          IMPORTING E_ROW_ID E_COLUMN_ID ES_ROW_NO,
    **Double Click Handler
        HANDLE_DOUBLE_CLICK FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
                                         IMPORTING E_ROW E_COLUMN ES_ROW_NO,
        TOP_OF_PAGE FOR EVENT TOP_OF_PAGE              "event handler
                             OF CL_GUI_ALV_GRID
                             IMPORTING E_DYNDOC_ID.
    *        END_OF_LIST FOR EVENT end_of_list              "event handler
    *                         OF CL_GUI_ALV_GRID
    *                         IMPORTING E_DYNDOC_ID.
    ENDCLASS.                    "lcl_event_handler DEFINITION
    *       CLASS lcl_event_handler IMPLEMENTATION
    CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
    *Handle Hotspot Click
      METHOD HANDLE_HOTSPOT_CLICK .
        CLEAR: V_ROW,V_COLUMN,V_ROW_NUM.
        V_ROW  = E_ROW_ID.
        V_COLUMN = E_COLUMN_ID.
        V_ROW_NUM = ES_ROW_NO.
    *    MESSAGE I000 WITH V_ROW 'clicked'.
        CLEAR IT_ROW_NO[].
        X_ROW_NO-ROW_ID = V_ROW.
        APPEND X_ROW_NO TO IT_ROW_NO .
        CALL METHOD G_GRID->SET_SELECTED_ROWS
          EXPORTING
            IT_ROW_NO = IT_ROW_NO.
      ENDMETHOD.                    "lcl_event_handler
    *Handle Double Click
      METHOD  HANDLE_DOUBLE_CLICK.
        CLEAR: V_ROW,V_COLUMN,V_ROW_NUM.
        V_ROW  = E_ROW.
        V_COLUMN = E_COLUMN.
        V_ROW_NUM = ES_ROW_NO.
        IF E_COLUMN = 'VBELN'.
          SET PARAMETER ID 'VL' FIELD ITAB-VBELN.
          CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN.
        ENDIF.
        IF E_COLUMN = 'POSNR'.
          SET PARAMETER ID 'VL' FIELD ITAB-VBELN.
          CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN."
        ENDIF.
      ENDMETHOD.                    "handle_double_click
    *  METHOD END_OF_LIST.                   "implementation
    ** Top-of-page event
    *    PERFORM EVENT_TOP_OF_PAGE USING DG_DYNDOC_ID.
    *  ENDMETHOD.                            "top_of_page
        METHOD TOP_OF_PAGE.                   "implementation
    * Top-of-page event
        PERFORM EVENT_TOP_OF_PAGE USING DG_DYNDOC_ID.
      ENDMETHOD.                            "top_of_page
    ENDCLASS.                    "LCL_EVENT_HANDLER IMPLEMENTATION
    *&             Global Definitions
    DATA:      G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,"Container1
                G_HANDLER TYPE REF TO LCL_EVENT_HANDLER. "handler
    DATA: OK_CODE LIKE SY-UCOMM,
          SAVE_OK LIKE SY-UCOMM,
          G_CONTAINER1 TYPE SCRFNAME VALUE 'TEST',
          GS_LAYOUT TYPE LVC_S_LAYO.
    data: v_lines type i.
    data: v_line(3) type c.
    *- Fieldcatalog for First and second Report
    DATA: IT_FIELDCAT  TYPE  LVC_T_FCAT,
          X_FIELDCAT TYPE LVC_S_FCAT,
          LS_VARI  TYPE DISVARIANT.
    *                START-OF_SELECTION
    START-OF-SELECTION.
      SELECT VBELN
             POSNR
             FROM LIPS
             UP TO 20 ROWS
             INTO CORRESPONDING FIELDS OF TABLE ITAB.
    describe table itab lines v_lines.
    END-OF-SELECTION.
      IF NOT ITAB[] IS INITIAL.
        CALL SCREEN 100.
      ELSE.
        MESSAGE I002 WITH 'NO DATA FOR THE SELECTION'(004).
      ENDIF.
    *&      Form  CREATE_AND_INIT_ALV
    *       text
    FORM CREATE_AND_INIT_ALV .
      DATA: LT_EXCLUDE TYPE UI_FUNCTIONS.
      "attention.....from here
      "split your container here...into two parts
      "create the container
      CREATE OBJECT G_CUSTOM_CONTAINER
               EXPORTING CONTAINER_NAME = G_CONTAINER1.
      "this is for top of page
    * Create TOP-Document
      CREATE OBJECT DG_DYNDOC_ID
                       EXPORTING STYLE = 'ALV_GRID'.
    * Create Splitter for custom_container
      CREATE OBJECT DG_SPLITTER
                 EXPORTING PARENT  = G_CUSTOM_CONTAINER
                           ROWS    = 2
                           COLUMNS = 1.
    * Split the custom_container to two containers and move the reference
    * to receiving containers g_parent_html and g_parent_grid
      "i am allocating the space for grid and top of page
      CALL METHOD DG_SPLITTER->GET_CONTAINER
        EXPORTING
          ROW       = 1
          COLUMN    = 1
        RECEIVING
          CONTAINER = DG_PARENT_HTML.
      CALL METHOD DG_SPLITTER->GET_CONTAINER
        EXPORTING
          ROW       = 2
          COLUMN    = 1
        RECEIVING
          CONTAINER = DG_PARENT_GRID.
    *  CALL METHOD DG_SPLITTER->GET_CONTAINER
    *    EXPORTING
    *      ROW       = 2
    *      COLUMN    = 1
    *    RECEIVING
    *      CONTAINER = DG_PARENT_HTML.
    *  CALL METHOD DG_SPLITTER->GET_CONTAINER
    *    EXPORTING
    *      ROW       = 1
    *      COLUMN    = 1
    *    RECEIVING
    *      CONTAINER = DG_PARENT_GRID.
      "you can set the height of it
    * Set height for g_parent_html
      CALL METHOD DG_SPLITTER->SET_ROW_HEIGHT
        EXPORTING
          ID     = 1
          HEIGHT = 5.
      "from here as usual..you need to specify parent as splitter part
      "which we alloted for grid
      CREATE OBJECT G_GRID
             EXPORTING I_PARENT = DG_PARENT_GRID.
    * Set a titlebar for the grid control
      CLEAR GS_LAYOUT.
      GS_LAYOUT-GRID_TITLE = TEXT-003.
      GS_LAYOUT-ZEBRA = SPACE.
      GS_LAYOUT-CWIDTH_OPT = 'X'.
      GS_LAYOUT-NO_ROWMARK = 'X'.
      GS_LAYOUT-CTAB_FNAME = 'CELLCOLOR'.
      CALL METHOD G_GRID->REGISTER_EDIT_EVENT
        EXPORTING
          I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_ENTER.
      CREATE OBJECT G_HANDLER.
      SET HANDLER G_HANDLER->HANDLE_DOUBLE_CLICK FOR G_GRID.
      SET HANDLER G_HANDLER->HANDLE_HOTSPOT_CLICK FOR G_GRID.
    *  SET HANDLER G_HANDLER->END_OF_LIST FOR G_GRID.
      SET HANDLER G_HANDLER->TOP_OF_PAGE FOR G_GRID.
      DATA: LS_CELLCOLOR TYPE LVC_S_SCOL. "required for color
      DATA: L_INDEX TYPE SY-TABIX.
      "Here i am changing the color of line 1,5,10...
      "so you can change the color of font conditionally
      LOOP AT ITAB.
        L_INDEX = SY-TABIX.
        IF L_INDEX = 1 OR L_INDEX = 5 OR L_INDEX = 10.
          LS_CELLCOLOR-FNAME = 'VBELN'.
          LS_CELLCOLOR-COLOR-COL = '6'.
          LS_CELLCOLOR-COLOR-INT = '0'.
          LS_CELLCOLOR-COLOR-INV = '1'.
          APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
          MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
          LS_CELLCOLOR-FNAME = 'POSNR'.
          LS_CELLCOLOR-COLOR-COL = '6'.
          LS_CELLCOLOR-COLOR-INT = '0'.
          LS_CELLCOLOR-COLOR-INV = '1'.
          APPEND LS_CELLCOLOR TO ITAB-CELLCOLOR.
          MODIFY ITAB INDEX L_INDEX TRANSPORTING CELLCOLOR.
        ENDIF.
      ENDLOOP.
    * setting focus for created grid control
      CALL METHOD CL_GUI_CONTROL=>SET_FOCUS
        EXPORTING
          CONTROL = G_GRID.
    * Build fieldcat and set editable for date and reason code
    * edit enabled. Assign a handle for the dropdown listbox.
      PERFORM BUILD_FIELDCAT.
      PERFORM  SET_DRDN_TABLE.
    * Optionally restrict generic functions to 'change only'.
    *   (The user shall not be able to add new lines).
      PERFORM EXCLUDE_TB_FUNCTIONS CHANGING LT_EXCLUDE.
    **Vaiant to save the layout
      LS_VARI-REPORT      = SY-REPID.
      LS_VARI-HANDLE      = SPACE.
      LS_VARI-LOG_GROUP   = SPACE.
      LS_VARI-USERNAME    = SPACE.
      LS_VARI-VARIANT     = SPACE.
      LS_VARI-TEXT        = SPACE.
      LS_VARI-DEPENDVARS  = SPACE.
    **Calling the Method for ALV output
      CALL METHOD G_GRID->SET_TABLE_FOR_FIRST_DISPLAY
        EXPORTING
          IT_TOOLBAR_EXCLUDING = LT_EXCLUDE
          IS_VARIANT           = LS_VARI
          IS_LAYOUT            = GS_LAYOUT
          I_SAVE               = 'A'
        CHANGING
          IT_FIELDCATALOG      = IT_FIELDCAT
          IT_OUTTAB            = ITAB[].
      "do these..{
    * Initializing document
      CALL METHOD DG_DYNDOC_ID->INITIALIZE_DOCUMENT.
    * Processing events
      CALL METHOD G_GRID->LIST_PROCESSING_EVENTS
        EXPORTING
          I_EVENT_NAME = 'TOP_OF_PAGE'
          I_DYNDOC_ID  = DG_DYNDOC_ID.
      "end }
    * Set editable cells to ready for input initially
      CALL METHOD G_GRID->SET_READY_FOR_INPUT
        EXPORTING
          I_READY_FOR_INPUT = 1.
    ENDFORM.                               "CREATE_AND_INIT_ALV
    *&      Form  EXCLUDE_TB_FUNCTIONS
    *       text
    *      -->PT_EXCLUDE text
    FORM EXCLUDE_TB_FUNCTIONS CHANGING PT_EXCLUDE TYPE UI_FUNCTIONS.
    * Only allow to change data not to create new entries (exclude
    * generic functions).
      DATA LS_EXCLUDE TYPE UI_FUNC.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_DELETE_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_APPEND_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_INSERT_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_MOVE_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_CUT.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_PASTE_NEW_ROW.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
      LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_UNDO.
      APPEND LS_EXCLUDE TO PT_EXCLUDE.
    ENDFORM.                               " EXCLUDE_TB_FUNCTIONS
    *&      Form  build_fieldcat
    *       Fieldcatalog
    FORM BUILD_FIELDCAT .
      DATA: L_POS TYPE I.
      L_POS = L_POS + 1.
      X_FIELDCAT-SCRTEXT_M = 'Delivery'(024).
      X_FIELDCAT-FIELDNAME = 'VBELN'.
      X_FIELDCAT-TABNAME = 'IT_FINAL'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-NO_ZERO    = 'X'.
      X_FIELDCAT-OUTPUTLEN = '10'.
      X_FIELDCAT-HOTSPOT = 'X'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
      L_POS = L_POS + 1.
      X_FIELDCAT-SCRTEXT_M = 'Item'(025).
      X_FIELDCAT-FIELDNAME = 'POSNR'.
      X_FIELDCAT-TABNAME = 'IT_FINAL'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-OUTPUTLEN = '5'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
      L_POS = L_POS + 1.
      X_FIELDCAT-SCRTEXT_M = 'Drop'(025).
      X_FIELDCAT-FIELDNAME = 'DROP'.
      X_FIELDCAT-TABNAME = 'IT_FINAL'.
      X_FIELDCAT-COL_POS    = L_POS.
      X_FIELDCAT-OUTPUTLEN = '5'.
      X_FIELDCAT-EDIT = 'X'.
      X_FIELDCAT-DRDN_HNDL = '1'.
      X_FIELDCAT-DRDN_ALIAS = 'X'.
      APPEND X_FIELDCAT TO IT_FIELDCAT.
      CLEAR X_FIELDCAT.
    ENDFORM.                    " build_fieldcat
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'MAIN100'.
      SET TITLEBAR 'MAIN100'.
      IF G_CUSTOM_CONTAINER IS INITIAL.
    **Initializing the grid and calling the fm to Display the O/P
        PERFORM CREATE_AND_INIT_ALV.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN 'BACK'.
          LEAVE TO SCREEN 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  SET_DRDN_TABLE
    *       text
    FORM SET_DRDN_TABLE.
      DATA:LT_DRAL TYPE LVC_T_DRAL,
            LS_DRAL TYPE LVC_S_DRAL.
      LOOP AT ITAB .
    * First listbox (handle '1').
        IF SY-INDEX = 1.
          LS_DRAL-HANDLE = '1'.
          LS_DRAL-VALUE =  ' '.
          LS_DRAL-INT_VALUE =  ' '.
        ELSE.
          LS_DRAL-HANDLE = '1'.
          LS_DRAL-VALUE =  ITAB-POSNR.
          LS_DRAL-INT_VALUE =  ITAB-POSNR.
        ENDIF.
        APPEND LS_DRAL TO LT_DRAL.
      ENDLOOP.
    **Setting the Drop down table for Reason Code
      CALL METHOD G_GRID->SET_DROP_DOWN_TABLE
        EXPORTING
          IT_DROP_DOWN_ALIAS = LT_DRAL.
    ENDFORM.                               " set_drdn_table
    *&      Form  EVENT_TOP_OF_PAGE
    *       text
    *      -->DG_DYNDOC_ID  text
    FORM EVENT_TOP_OF_PAGE USING   DG_DYNDOC_ID TYPE REF TO CL_DD_DOCUMENT.
      "this is more clear.....check it
      "first add text, then pass it to comentry write fm
      DATA : DL_TEXT(255) TYPE C.  "Text
    * Populating header to top-of-page
      CALL METHOD DG_DYNDOC_ID->ADD_TEXT
        EXPORTING
          TEXT      = 'Test Report'
          SAP_STYLE = CL_DD_AREA=>HEADING.
    * Add new-line
      CALL METHOD DG_DYNDOC_ID->NEW_LINE.
      CLEAR : DL_TEXT.
    * Move program ID
      CONCATENATE 'Program Name :' SY-REPID
             INTO DL_TEXT SEPARATED BY SPACE.
    * Add Program Name to Document
      PERFORM ADD_TEXT USING DL_TEXT.
    * Add new-line
      CALL METHOD DG_DYNDOC_ID->NEW_LINE.
      CLEAR : DL_TEXT.
    * Move User ID
      CONCATENATE 'User ID :' SY-UNAME INTO DL_TEXT SEPARATED BY SPACE
    * Add User ID to Document
      PERFORM ADD_TEXT USING DL_TEXT.
    * Add new-line
      CALL METHOD DG_DYNDOC_ID->NEW_LINE.
      CLEAR : DL_TEXT.
    * Move count (no of records).
      move v_lines to v_line.
      CONCATENATE 'No of records :' v_line INTO DL_TEXT SEPARATED BY SPACE.
    * Add Client to Document
      PERFORM ADD_TEXT USING DL_TEXT.
    * Add new-line
      CALL METHOD DG_DYNDOC_ID->NEW_LINE.
      CLEAR : DL_TEXT.
    * Move date
      WRITE SY-DATUM TO DL_TEXT.
      CONCATENATE 'Date :' DL_TEXT INTO DL_TEXT SEPARATED BY SPACE.
    * Add Date to Document
      PERFORM ADD_TEXT USING DL_TEXT.
    * Add new-line
      CALL METHOD DG_DYNDOC_ID->NEW_LINE.
      CLEAR : DL_TEXT.
    * Move time
      WRITE SY-UZEIT TO DL_TEXT.
      CONCATENATE 'Time :' DL_TEXT INTO DL_TEXT SEPARATED BY SPACE.
    * Add Time to Document
      PERFORM ADD_TEXT USING DL_TEXT.
    * Add new-line
      CALL METHOD DG_DYNDOC_ID->NEW_LINE.
    * Populating data to html control
      PERFORM HTML.
    ENDFORM.                    " EVENT_TOP_OF_PAGE
    *&      Form  ADD_TEXT
    *       To add Text
    FORM ADD_TEXT USING P_TEXT TYPE SDYDO_TEXT_ELEMENT.
    * Adding text
      CALL METHOD DG_DYNDOC_ID->ADD_TEXT
        EXPORTING
          TEXT         = P_TEXT
          SAP_EMPHASIS = CL_DD_AREA=>HEADING.
    ENDFORM.                    " ADD_TEXT
    *&      Form  HTML
    *       text
    FORM HTML.
      DATA : DL_LENGTH  TYPE I,                           " Length
             DL_BACKGROUND_ID TYPE SDYDO_KEY VALUE SPACE. " Background_id
    * Creating html control
      IF DG_HTML_CNTRL IS INITIAL.
        CREATE OBJECT DG_HTML_CNTRL
             EXPORTING
                  PARENT    = DG_PARENT_HTML.
      ENDIF.
    * Reuse_alv_grid_commentary_set
      CALL FUNCTION 'REUSE_ALV_GRID_COMMENTARY_SET'
        EXPORTING
          DOCUMENT = DG_DYNDOC_ID
          BOTTOM   = SPACE
        IMPORTING
          LENGTH   = DL_LENGTH.
    * Get TOP->HTML_TABLE ready
      CALL METHOD DG_DYNDOC_ID->MERGE_DOCUMENT.
    * Set wallpaper
      CALL METHOD DG_DYNDOC_ID->SET_DOCUMENT_BACKGROUND
        EXPORTING
          PICTURE_ID = DL_BACKGROUND_ID.
    * Connect TOP document to HTML-Control
      DG_DYNDOC_ID->HTML_CONTROL = DG_HTML_CNTRL.
    * Display TOP document
      CALL METHOD DG_DYNDOC_ID->DISPLAY_DOCUMENT
        EXPORTING
          REUSE_CONTROL      = 'X'
          PARENT             = DG_PARENT_HTML
        EXCEPTIONS
          HTML_DISPLAY_ERROR = 1.
      IF SY-SUBRC NE 0.
        MESSAGE I999 WITH 'Error in displaying top-of-page'(036).
      ENDIF.
    ENDFORM.                    " HTML

  • Dopdown Listbox in ALV Grid OO Concept

    Is it possible to put a dropdownlist bow for an alv grid?
    Is it possible to put different List of values for same cell of column ?
    How do we do it ?
    regards,

    Hi,
    steps..
    1. X_FIELDCAT-DRDN_HNDL = '1'. "pass this to the field you want to show as drop down
    2.
    DATA: X_OCRC LIKE LINE OF IT_OCRC.
      DATA:LT_DRAL TYPE LVC_T_DRAL,
            LS_DRAL TYPE LVC_S_DRAL.
      LOOP AT IT_OCRC INTO X_OCRC.
    * First listbox (handle '1').
        IF SY-INDEX = 1.
          LS_DRAL-HANDLE = '1'.
          LS_DRAL-VALUE =  ' '.
          LS_DRAL-INT_VALUE =  ' '.
        ELSE.
          LS_DRAL-HANDLE = '1'.
          LS_DRAL-VALUE =  X_OCRC-COMBI.
          LS_DRAL-INT_VALUE =  X_OCRC-COMBI.
        ENDIF.
        APPEND LS_DRAL TO LT_DRAL.
      ENDLOOP.
    **Setting the Drop down table for field1
      CALL METHOD G_GRID->SET_DROP_DOWN_TABLE
        EXPORTING
          IT_DROP_DOWN_ALIAS = LT_DRAL.
    Regards
    vijay

  • Grid not taking full width in Listbox in large device

    I am trying to create a listbox in which grid takes the full width of the device automatically and adjusts accordingly. But earlier it was not taking the full width and now it has stopped viewing items.
    Here is my code
    <ListBox Name="costList" HorizontalContentAlignment="Stretch" Grid.Row="2" Height="400" ItemContainerStyle="{StaticResource ListBoxItemStyle1}">
                                    <ListBox.ItemTemplate>
                                        <DataTemplate>
                                            <Grid HorizontalAlignment="Stretch" Background="Black">
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="1*"/>
                                                    <ColumnDefinition Width="1*"/>
                                                    <ColumnDefinition Width="0.3*"/>
                                                    <ColumnDefinition Width="1*"/>
                                                    <ColumnDefinition Width="1*"/>
                                                </Grid.ColumnDefinitions>
                                                <TextBlock Grid.Row="1" Grid.Column="0" Text="Groceries" Style="{StaticResource
    Content_Text}" Padding="2,0" Foreground="Black" Width="Auto" Height="Auto" HorizontalAlignment="Center" FontSize="16" VerticalAlignment="Center" Margin="2"/>
                                                <Image Grid.Row="1" Grid.Column="1" MaxHeight="35" MaxWidth="100"
    Stretch="Fill" Source="/Images/around_me_btm_img.png"/>
                                                <TextBlock Grid.Row="1" Grid.Column="1" Text="$" Style="{StaticResource
    Content_Text}" Padding="2,0" Foreground="Black" Width="15" Height="24" HorizontalAlignment="Left" FontSize="22" Margin="2,4,0,10"/>
                                                <TextBox Grid.Row="1" Grid.Column="1" HorizontalAlignment="Left" InputScope="Number"
    MaxLength="6" PlaceholderText="0.0" Background="Transparent" BorderBrush="Transparent" Padding="0,0,2,0" Width="60" Height="10" VerticalAlignment="Center" FlowDirection="RightToLeft"
    Foreground="Black" Margin="20,0,0,0" BorderThickness="0"/>
                                                <TextBlock Grid.Row="1" Grid.Column="2" Text="2%" VerticalAlignment="Center"
    Foreground="Black" TextAlignment="Center" Padding="0" Width="Auto" FontSize="16"/>
                                                <Image Grid.Row="1" Grid.Column="3" MaxHeight="35" MaxWidth="100"
    Stretch="Fill" Source="/Images/around_me_btm_img.png"/>
                                                <TextBlock Grid.Row="1" IsHitTestVisible="False" Grid.Column="3" Text="$"
    Style="{StaticResource Content_Text}" Padding="2,0" Foreground="Black" Width="15" Height="24" HorizontalAlignment="Left" FontSize="22" Margin="2,4,0,10"/>
                                                <TextBox Grid.Row="1" Grid.Column="3" IsHitTestVisible="False" HorizontalAlignment="Left"
    InputScope="Number" MaxLength="6"  PlaceholderText="0.0" Background="Transparent" BorderBrush="Transparent" Padding="0,0,2,0" Width="60" Height="10" VerticalAlignment="Center"
    FlowDirection="RightToLeft" Foreground="Black" Margin="20,0,0,0" BorderThickness="0"/>
                                                <Image Grid.Row="1" Grid.Column="4" MaxHeight="35" MaxWidth="100"
    Stretch="Fill" Source="/Images/around_me_btm_img.png"/>
                                                <TextBlock Grid.Row="1" Grid.Column="4" Text="$" Style="{StaticResource
    Content_Text}" Padding="2,0" Foreground="Black" Width="15" Height="24" HorizontalAlignment="Left" FontSize="22" Margin="2,4,0,10"/>
                                                <TextBox Grid.Row="1" IsHitTestVisible="False" Grid.Column="4" HorizontalAlignment="Left"
    InputScope="Number" MaxLength="6"  PlaceholderText="0.0" Background="Transparent" BorderBrush="Transparent" Padding="0,0,2,0" Width="60" Height="10" VerticalAlignment="Center"
    FlowDirection="RightToLeft" Foreground="Black" Margin="20,0,0,0" BorderThickness="0"/>
                                            </Grid>
                                        </DataTemplate>
                                    </ListBox.ItemTemplate>                            
                                </ListBox>
    List<string> demoList = new List<string>();
                for (int i = 0; i < 5; i++)
                    demoList.Add("Hello");
                costList.ItemsSource = demoList;
    Here demolist is just for testing purpose because I want to bind the textblock on leftmost column to it. Can somebody help?

    Hi RohitrkKumar,
    You’ve not posted the definition of ItemContainerStyle, so I used the default one with your code. I could see the item of ListBox control taking the full width of screen. I tested using snapped view and it worked fine.
    Please try and let me know the result. If you still cannot make it working, please post more information about your scenario.
    Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate
    the survey.

  • How to access the texblocks in a listbox?

    Hi All,
    I have a listbox which I can successfully update with the data but now I want to access two specific textblocks which I want to  collapse and make the other visible.
    <ListBox Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="3" HorizontalAlignment="Stretch" Name="myPM_MListBox" Margin="-5,0,-5,0" SelectionChanged="myPMListBox_SelectionChanged">
    <ListBox.ItemContainerStyle>
    <Style TargetType="ListBoxItem">
    <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
    </Style>
    </ListBox.ItemContainerStyle>
    <ListBox.ItemTemplate>
    <DataTemplate>
    <Grid Margin="0,0,0,0" HorizontalAlignment="Stretch">
    <Grid.RowDefinitions>
    <RowDefinition Height="Auto"/>
    <RowDefinition Height="Auto"/>
    <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
    <ColumnDefinition Width="150" />
    <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>
    <Border Grid.Row="0" Grid.Column="0" Margin="5,0,0,0" Background="#FF009E49" BorderThickness="1" BorderBrush="#FF505050">
    <TextBlock Margin="5,5,5,5" Text="Message Date" FontSize="16" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" Foreground="#FFFFFFFF" FontWeight="Normal"/>
    </Border>
    <Border Grid.Row="0" Grid.Column="1" Margin="0,0,5,0" Background="#FFEFEFEF" BorderThickness="1" BorderBrush="#FF505050">
    <TextBlock Margin="5,5,5,5" x:Name="PMMessagePubDate" Text="{Binding shdMsgPublishTime}" FontSize="16" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" Foreground="#FF000000" FontWeight="Normal"/>
    </Border>
    <Border Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Margin="5,0,5,0" Background="#FFEFEFEF" BorderThickness="1,1,1,0" BorderBrush="#FF505050">
    <TextBlock Margin="5,5,5,5" x:Name="PM_MLimitedBody" Text="{Binding shdMessageText}" FontSize="16" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" Foreground="#FF000000" FontWeight="Normal"/>
    </Border>
    <Border Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Margin="5,0,5,0" Background="#FFEFEFEF" BorderThickness="1,0,1,1" BorderBrush="#FF505050">
    <TextBlock Margin="5,5,5,5" x:Name="PM_MFullBody" Text="Show more..." FontSize="16" HorizontalAlignment="right" TextWrapping="Wrap" VerticalAlignment="Top" Foreground="Blue" FontWeight="Normal" Tapped="ShowFullBody_Tap"/>
    </Border>
    </Grid>
    </DataTemplate>
    </ListBox.ItemTemplate>
    </ListBox>
    I want to hide PM_MLimitedBody textblock and show the PM_MFullBody textblock for the ShowFullBody_Tap event handler I have. But seems like I can't access the Visibility properties of these textblok in my .cs file. is there a way for me to
    access these textblock's visibility property in my .cs file?
    Thank You!   
    mujno

    Hi Mujno,
    >>I want to hide PM_MLimitedBody textblock and show the PM_MFullBody textblock for the ShowFullBody_Tap event handler I have. But seems like I can't access the Visibility properties of these textblok in my .cs file. is there a way
    for me to access these textblock's visibility property in my .cs file?
    Yes, as you said, we can not access the textblock controls which are in the DataTemplate by using their names in the .cs file. But we can use the
    VisualTreeHelper to help us find these textblock controls.
    I have created the following example, in my example the PM_MLimitedBody textblock will be hidden in the ShowFullBody_Tap event, for more information, please try to check it:
    private void ShowFullBody_Tap(object sender, TappedRoutedEventArgs e)
    TextBlock MyTextBlock = (TextBlock)MyFindListBoxChildByName(this.myPM_MListBox.ContainerFromItem(this.myPM_MListBox.SelectedItem), "PM_MLimitedBody");
    MyTextBlock.Visibility = Visibility.Collapsed;
    public static DependencyObject MyFindListBoxChildByName(DependencyObject parant, string ControlName)
    int count = VisualTreeHelper.GetChildrenCount(parant);
    for (int i = 0; i < count; i++)
    var MyChild = VisualTreeHelper.GetChild(parant, i);
    if (MyChild is FrameworkElement && ((FrameworkElement)MyChild).Name == ControlName)
    return MyChild;
    var FindResult = MyFindListBoxChildByName(MyChild, ControlName);
    if (FindResult != null)
    return FindResult;
    return null;
    Best Regards,
    Amy Peng
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • WPF listbox image binding

    Good morning,
    I already implemented a application that loads images from a directory to a listbox. All ok but the loading takes about 5 seconds to display around 20-30 images. Is there a way to decrease the time needed for the images to be loaded. Or is it correct to
    display an loading image in front of the UI so the user knows images are loading? Thank you in advance for the help. Below is my xaml code for the listbox.
    <ListBox Name="Images" ListBox.SelectionChanged="lstImagesChange_Click" Grid.Column="1"
    ScrollViewer.HorizontalScrollBarVisibility="Disabled" VirtualizingStackPanel.IsVirtualizing="false"
    VirtualizingStackPanel.VirtualizationMode="Recycling" ScrollViewer.IsDeferredScrollingEnabled="True">
    <ListBox.Resources>
    <Style x:Key="{x:Type ScrollBar}" TargetType="{x:Type ScrollBar}">
    <Style.Triggers>
    <Trigger Property="Orientation" Value="Vertical">
    <Setter Property="Width" Value="20"/>
    <Setter Property="Height" Value="Auto" />
    </Trigger>
    </Style.Triggers>
    </Style>
    </ListBox.Resources>
    <ListBox.ItemsPanel>
    <ItemsPanelTemplate>
    <WrapPanel IsItemsHost="True" Orientation="Horizontal" FlowDirection="LeftToRight" />
    </ItemsPanelTemplate>
    </ListBox.ItemsPanel>
    <ListBox.ItemTemplate>
    <DataTemplate>
    <Border BorderThickness="2" BorderBrush="#bb62d8" Background="Black" Width="200" Height="200" Margin="5,5,10,5" CornerRadius="10">
    <Image Source="{Binding Path=Path, Converter={StaticResource UriToBitmapConverter}}" Tag="{Binding ImageID}" />
    </Border>
    </DataTemplate>
    </ListBox.ItemTemplate>
    </ListBox>
    and below is the code loading the images
    if (!(images == null))
    Images.ItemsSource = images;

    Hmm, so are your images really 150x150 or are they larger than that?
    Anyway, here's one solution to show a "loading" image and not block the UI while all images are loading. You seem to already have some class with a Path property which you use as image Source. Let's say ImageItem
    public class ImageItem : INotifyPropertyChanged
    private static ImageSource loadingImage;
    private ImageSource image;
    private Task loadingTask;
    private string path;
    public string Path
    get { return path; }
    set { path = value; }
    public ImageSource Image {
    get {
    if (image == null) {
    if (loadingTask == null) {
                        if (loadingImage == null)
                            loadingImage = new BitmapImage(new Uri("loading.png", UriKind.Relative));
                         image = loadingImage;
    loadingTask = Task.Run<BitmapImage>(() => {
    var bi = new BitmapImage();
    bi.BeginInit();
    bi.DecodePixelWidth = 64;
    bi.CacheOption = BitmapCacheOption.OnLoad;
    bi.UriSource = new Uri(path);
    bi.EndInit();
    bi.Freeze();
    return bi;
    }).ContinueWith(t => {
    Image = t.Result;
    loadingTask = null;
    }, TaskScheduler.FromCurrentSynchronizationContext());
    return image;
    private set {
    if (image == value)
    return;
    image = value;
    OnPropertyChanged("Image");
    private void OnPropertyChanged(string propertyName)
    if (PropertyChanged != null)
    PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    public event PropertyChangedEventHandler PropertyChanged;
    In summary:
    there's a new Image property, bind Image.Source to that instead of Path
    when the Image property is read for the first time it will start a task which loads the actual image and return loadingImage instead of the real image
    when the loading task completes it will set the Image property to the loaded image. This will raise a property changed notification that will update the Image control in the UI.
    of course, the converter is no longer needed
    "loading.png" must be part of the project and in the same folder as the XAML file
    Caveats:
    This works well for a relatively small number of images like 20-30. For more images you'd really need a WrapPanel that supports virtualization, that would allow images to be loaded as the user scrolls through the list. Without virtualization all images will
    be loaded and even if the UI doesn't lock up you'll saturate the CPU for a long time with so many tasks.

  • How to use double click trigger in ListBoxItem template?

    Hi all,
    I want to double click listBoxItem in listbox, and set this item as editable status. It says make textbox as visible, please see the below code. When press Enter key or lost focus, then make textbox as invisible and textblock as visible. It's better to use
    trigger to switch the status, but I do not know how to do it, thanks!
    <Setter Property="Template">
    <Setter.Value>
    <ControlTemplate TargetType="ListBoxItem">
    <Grid>
    <TextBlock Text="{Binding FirstName}" />
    <TextBox Text="{Binding FirstName}"/>
    </Grid>
    </ControlTemplate>
    </Setter.Value>
    </Setter>

    Did you consider using a DataGrid? This control has editing capabilities built-in:
    https://msdn.microsoft.com/en-us/library/system.windows.controls.datagrid(v=vs.110).aspx
    Otherwise you could add a boolean property to the class with the FirstName property, toggle this one in an event handler for the MouseDoubleClick event of the ListBoxItem and then use data triggers. Here is an example for you that should give you the
    idea:
    <ListBox x:Name="lb1">
    <ListBox.ItemContainerStyle>
    <Style TargetType="ListBoxItem">
    <EventSetter Event="MouseDoubleClick" Handler="OnMouseDoubleClick"/>
    </Style>
    </ListBox.ItemContainerStyle>
    <ListBox.ItemTemplate>
    <DataTemplate>
    <Grid>
    <TextBlock x:Name="tb" Text="{Binding FirstName}" Visibility="Visible"/>
    <TextBox x:Name="tx" Text="{Binding FirstName}" Visibility="Collapsed"
    LostKeyboardFocus="tx_LostFocus" PreviewKeyDown="tx_PreviewKeyDown"/>
    </Grid>
    <DataTemplate.Triggers>
    <DataTrigger Binding="{Binding IsInEditMode}" Value="True">
    <Setter TargetName="tb" Property="Visibility" Value="Collapsed"/>
    <Setter TargetName="tx" Property="Visibility" Value="Visible"/>
    </DataTrigger>
    </DataTemplate.Triggers>
    </DataTemplate>
    </ListBox.ItemTemplate>
    </ListBox>
    public MainWindow()
    InitializeComponent();
    List<YourItem> myDataType = new List<YourItem>()
    new YourItem{ FirstName = "Name..."}
    lb1.ItemsSource = myDataType;
    private void OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
    ListBoxItem lbi = sender as ListBoxItem;
    YourItem item = lbi.DataContext as YourItem;
    if (item != null)
    item.IsInEditMode = !item.IsInEditMode;
    private void tx_LostFocus(object sender, RoutedEventArgs e)
    TextBox txt = sender as TextBox;
    YourItem item = txt.DataContext as YourItem;
    if (item != null)
    item.IsInEditMode = false;
    private void tx_PreviewKeyDown(object sender, KeyEventArgs e)
    if (e.Key == Key.Return)
    e.Handled = true;
    TextBox txt = sender as TextBox;
    YourItem item = txt.DataContext as YourItem;
    if (item != null)
    item.IsInEditMode = false;
    Make sure that your model class implements the INotifyPropertyChanged interface correctly:
    public class YourItem : INotifyPropertyChanged
    public string FirstName { get; set; }
    private bool _isInEditMode;
    public bool IsInEditMode
    get { return _isInEditMode; }
    set { _isInEditMode = value; NotifyPropertyChanged("IsInEditMode"); }
    public event PropertyChangedEventHandler PropertyChanged;
    private void NotifyPropertyChanged(string propertyName)
    if (PropertyChanged != null)
    PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    Hope that helps.
    Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't post several questions in the same thread.

  • Drop Down in cl_gui_alv_grid

    Hi ,
    Can anyone Please tell me how to get the value from one drop down box and put the  corresponding value in another Drop downbox.
    e.g.
    Field A ---> DropDown -
    Values '1' and '2'
    So , if i press 1 from Field A
    the in Field B -
    > Drop Down it should come as 'A' 'B' 'C'.

    Hi,
    Check the sample programs.
    BCALV_EDIT_06
    BCALV_EDIT_07
    For more info check this thread,
    Re: listbox in alv grid output -Possible?
    Regards
    Adil

  • How can i make a list like Razer Game Booster in wpf C#

    Hello every one
    I asked this question in stackoverflow, and they just gave me negative points! I don't know why,
    but at least
    I expected to get answer in here.
    I trying to make a software with WPF in C# that the theme is
    similar to Razer Game Booster.
    I made many effect similar to
    Razer Game Booster in my software but I don't Know how can i make a list like that software!
    You can download Razer Game Booster in this link: http://www.razerzone.com/cortex/download
    Now, What exactly i want?! I'll show you with following pics:
    After adding a few items, a scroll bar will appear and if you do nothing, it will be hidden after a few seconds:
    Image link: http://imgur.com/XIl3Bk9
    After placing the mouse on the items (on hover status):
    Image link: http://imgur.com/8NbUrIx
    Which one of objects in visual C# and WPF Application can do this?!
    if you interested to see what I've done, unfortunately I tried it and
    failed! Now I asking you to help me and show me how can i do that?
    any advice can help me. I'm waiting for your answer.
    thank you guys so much.
    I'm sorry
    if I bothering you.

    There are probably 1000's of tutorial about layout in WPF but I have found that the people on this forum have the best handle on how to use WPF.  I am now near a workstation and have the following code example which should get you started. (the example
    is in VB but it is the XAML which is important).
    <Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded">
    <Window.Resources>
    <Style TargetType="ListBox" x:Key="myListbox" >
    <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden"></Setter>
    <Style.Triggers>
    <Trigger Property="IsMouseOver" Value="True">
    <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Visible" ></Setter>
    </Trigger>
    </Style.Triggers>
    </Style>
    </Window.Resources>
    <Grid Background="#FF040404">
    <ListBox Style="{StaticResource myListbox }"
    HorizontalAlignment="Left" Height="237" Margin="23,46,0,0"
    VerticalAlignment="Top" Width="470"
    ItemsSource="{Binding theList}" Background="Transparent" >
    <ListBox.ItemsPanel>
    <ItemsPanelTemplate>
    <UniformGrid Rows="2"></UniformGrid>
    </ItemsPanelTemplate>
    </ListBox.ItemsPanel>
    <ListBox.ItemTemplate>
    <DataTemplate>
    <Grid Background="#FF574A4A" Width="150" Height="75" Margin="0,0,10,0" >
    <TextBlock Text="{Binding theCaption}" VerticalAlignment="Bottom" Foreground="#FFF5EFEF"></TextBlock>
    </Grid>
    </DataTemplate>
    </ListBox.ItemTemplate>
    </ListBox>
    </Grid>
    </Window>
    Class MainWindow
    Public Property theList As New List(Of theItem)
    Private Sub Window_Loaded(sender As Object, e As RoutedEventArgs)
    For i As Integer = 0 To 5
    Dim ti As New theItem With {.theCaption = "Caption " + i.ToString}
    theList.Add(ti)
    Next
    DataContext = Me
    End Sub
    End Class
    Public Class theItem
    Public Property theCaption As String
    End Class
    The above XAML define a listbox with the properties I mentioned in my previous post.  There is a listbox with an ItemTemplate (define how each item should be displayed) and a definition of how the layout
    should be done (ItemsPanel).  The is also a style which uses datatriggers to show/hide your scrollbar.  If you have questions about what I presented please ask but I would ask that you try it first so that you can see how it looks .
    And I'm sorry for the small font above but this forum editor constantly give me problems.
    Lloyd Sheen

  • Binding in DataTemplate WPF

    Hi everyone,
    I'm now making a simple File Manager app. My application contains a ListBox whose ItemsSource={Binding FileList}
    Each item of my listBox is defined with custom item template which is used for displaying the status of file
    <ListBox.ItemsPanel>
    <ItemsPanelTemplate>
    <StackPanel/>
    </ItemsPanelTemplate>
    </ListBox.ItemsPanel>
    <ListBox.ItemTemplate>
    <DataTemplate>
    <Grid Height="23">
    <Grid.ColumnDefinitions>
    <ColumnDefinition Width="23"/>
    <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <Image Stretch="Fill"/>
    <TextBlock Margin="10, 0, 0, 0"
    Text="{Binding LastModified}"
    VerticalAlignment="Center"
    HorizontalAlignment="Left"
    Grid.Column="1"/>
    </DataTemplate>
    </ListBox.ItemTemplate>
    As you see, each item has an Image . I want that Image to be displayed as Locked if 2 conditions are satisfied : DateTime.Now - LastModified < 60 and Path is exists
    (LastModified and Path are property of FileList) . I'm thinking about MultiBinding but tried so many time with failure 
    Can anyone help me please ? 
    Thank you

    You could use a converter and a DataTrigger that sets some property of the Image (Source or Opacity for example) based on whether the condition is true or false:
    namespace WpfApplication22
    class CustomConverter : IValueConverter
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
    FileList item = value as FileList;
    if (item != null && string.IsNullOrEmpty(item.Path) && System.IO.File.Exists(item.Path) && (DateTime.Now.Date.Subtract(item.LastModified.Date).TotalDays < 60))
    return true;
    return false;
    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) {
    throw new NotImplementedException();
    <ListBox ItemsSource="{Binding FileList}" xmlns:local="clr-namespace:WpfApplication22">
    <ListBox.Resources>
    <local:CustomConverter x:Key="conv"/>
    </ListBox.Resources>
    <ListBox.ItemTemplate>
    <DataTemplate>
    <Grid Height="23">
    <Grid.ColumnDefinitions>
    <ColumnDefinition Width="23"/>
    <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <Image Stretch="Fill" >
    <Image.Style>
    <Style TargetType="Image">
    <Setter Property="Source" Value="av1.png"/>
    <Style.Triggers>
    <DataTrigger Binding="{Binding Path=., Converter={StaticResource conv}}" Value="True">
    <Setter Property="Opacity" Value="0.5"/>
    <!-- or set the source -->
    <!--<Setter Property="Source" Value="locked.png"/>-->
    </DataTrigger>
    </Style.Triggers>
    </Style>
    </Image.Style>
    </Image>
    <TextBlock Margin="10, 0, 0, 0" Text="{Binding LastModified}" VerticalAlignment="Center" HorizontalAlignment="Left" Grid.Column="1"/>
    </Grid>
    </DataTemplate>
    </ListBox.ItemTemplate>
    </ListBox>
    There is no reason to use a multi-converter here since you can bind to the FileList (or whatever your class is called) itself as shown in the above sample code.
    Hope that helps.
    Please remember to close your threads by marking helpful posts as answer.

  • Hubsections and ContentTemplate and ContentControl

    I have a simple windows store app, based on the hub template.
    The main hub contains 8 very similar hubsections. So instead of copy/pasting each hubsection properties I'd like to use some kind of template.
    Each hubsection is like so:
    <HubSection Width="350" x:Uid="HubSection1" Header="Header1">
    <DataTemplate>          
    <ListBox x:Name="lbMilitary" ItemsSource="{Binding}" Grid.Column="1" Background="Red">
    <ListBox.ItemTemplate>
    <DataTemplate>
    <Grid>
    <Grid.ColumnDefinitions>
    <ColumnDefinition Width="auto"></ColumnDefinition>
    <ColumnDefinition Width="12"></ColumnDefinition>
    <ColumnDefinition Width="*"></ColumnDefinition>
    </Grid.ColumnDefinitions>
    <TextBlock Style="{StaticResource PlayerNameTextBlockTemplate}" Text="{Binding PlayerName}"/>
    <TextBox Text="{Binding PlayerScore1, Mode=TwoWay}"  Style="{StaticResource TbTemplate}/>
    </Grid>      
    </DataTemplate>
    </ListBox.ItemTemplate>
    </ListBox>
    </DataTemplate>
    </HubSection>
    So, to simplify my XAML I have written a contentcontrol, like so:
    <Page.Resources>
    <ResourceDictionary>
    <DataTemplate x:Key="TemplateTest">
    <ContentControl>
    <Grid>
    <Grid.ColumnDefinitions>
    <ColumnDefinition Width="auto" />
    <ColumnDefinition Width="24" />
    <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <ListBox Grid.Column="0">
    <ListBox.ItemTemplate>
    <DataTemplate>
    <TextBlock FontSize="32" Text="{Binding PlayerName}"/>
    </DataTemplate>
    </ListBox.ItemTemplate>
    </ListBox>
    </Grid>
    </ContentControl>
    </DataTemplate>
    </ResourceDictionary>
    </Page.Resources>
    And I am trying to use this template like so:
    <HubSection x:Name="HubSecTest" Header="Test" ContentTemplate="{StaticResource TemplateTest}"> </HubSection>
    If inside my control I simply insert a simple element such as a textblock, it seems to be working. But with a listbox (such as the one in the full hubsection model), nothing displays.
    What am I doing wrong ?
    Also, another difficulty is that in my TextBox that is bound to PlayerScore I would like to be able to choose a specific binding for each separate hubsection, like so :
    <HubSection x:Name="HubSecTest" Header="Test" ContentTemplate="{StaticResource TemplateTest}">
    <!-- Bind the textblock to "PlayerName" -->
    <!-- Bind the TextBox to "PlayerScore1" -->
    </HubSection>
    <!-- Next hubsection -->
    <HubSection x:Name="HubSecTest" Header="Test" ContentTemplate="{StaticResource TemplateTest}">
    <!-- Bind the textblock to "PlayerName" as in the previous section BUT -->
    <-- Bind the TextBox to "PlayerScore2" -->
    </HubSection>
    Thanks :)

    Thank you very much for your answer.
    I'll try to answer your question as accurately as possible (I'm still rather new to all this ...).
    Both TextBlock and TextBox are included in a single ListBox in my basic design, as you can see in the first code example. Therefore, I guess my second code example is incomplete since the template should also include a TextBox in addition to the TextBlock,
    like so :
    <DataTemplate x:Key="TemplateTest">
    <ContentControl>
    <Grid>
    <Grid.ColumnDefinitions>
    <ColumnDefinition Width="auto" />
    <ColumnDefinition Width="24" />
    <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <ListBox Grid.Column="0">
    <ListBox.ItemTemplate>
    <DataTemplate>
    <TextBlock FontSize="32" Text="{Binding PlayerName}"/>
    <TextBox Text="{Binding}"/>
    </DataTemplate>
    </ListBox.ItemTemplate>
    </ListBox>
    </Grid>
    </ContentControl>
    </DataTemplate>
    Here, I have left <TextBox Text={Binding}"/> since in each separate HubSection I would like to be able to bind this TextBox to different properties (while the TextBlock will always be bound to PlayerName).
    From your answer, I understand that this is not possible and that I should use 2 ListBox in my template.
    However, I do not understand how I could do so. How would it be possible in XAML ? (if not, should I do it from code behind and how ?)
    For example, what could I do when defining the HubSection below ?
    <HubSection x:Name="HubSecTest" Header="Test" ContentTemplate="{StaticResource TemplateTest}">
    </HubSection>
    Is there a code that could allow binding the TextBlock or TexBox to different properties (for the TextBlock it is easy since I can define it in the template) ?
    The itemsource is indeed the same. I have created a class called Players.cs into which the properties Players.PlayerName and Players.PlayerScore<1..n> are defined.
    Thank you again for your time.

  • Building a TreeView control without ActiveX

    It's interesting, how to build TreeView control in LabVIEW without using of ActiveX technology? For example, LabVIEW Menu Editor (see attachment) has such control. This control seems to be developed in LabVIEW. Are anyone know, how to program such control? I have only idea to use multicolumn ListBox with hidden grid lines. But I can not insert picture (or color text) in it. The developers of LabVIEW can do it (see attachment)!
    Attachments:
    TreeView.zip ‏11 KB

    Ah yes, another LabVIEW "Holy Grail".
    I think you may be making a huge assumption that this wizard was created in LabVIEW. NI doesn't always use LabVIEW for these things.
    To see an example of what I believe is the best you can do with LabVIEW's standard tools to create a "tree view" check out the File Manager, located in the "Tools" menu under "VI Library Manager". This is a shining example of the best that most people can do using a List Control and the available symbols.
    Don't get me wrong, LabVIEW is capable of creating a true list view; however; you don't have the patience to write the code, as I would never try that.
    Perhaps someone will (or already has) created one, and has made this available. If you find one, let us all know, because we a
    re all seeking this Holy Grail too...
    PS: If I had to make a bet, I would guess that this wizard was either created using Visual C++, or perhaps even Visual Basic. Just don't tell anyone at NI I said the VB word...

  • Display listbox key value in ALV GRID method

    Hi All,
    I have a program in which columns are generted dynamically based on number of fields. The column name is dynamic as it depends on its text while The value in Column's can be 1, 2, 3, 4, 5.
    I am trying to display this in a list box along with the text which are maintained as fixed values at domain level.
    space Walking
    1       Archery   
    2       Boxing
    3       Cycling
    4       Rowing
    Also I am displaying by using 'DD_DOMVALUEs_GET, looping through all the fixed values and concatenate
    domvalue_l   ddtext separated by cl_abap_char_utilities=>horizontal_tab. No tab space is coming between key and value.
    Also for the 1st value which is space it is not coming properly as space is condensed.
    The point is that after I am putting values in the grid. The system event data changed is called where the value selected is  1 Archery and it is going to bad cells, error protocol display . I want only the 1st character. How to modify the content in the grid before the system event gets called.
    Regards,
    DPM

    Hi,
    try follow code to setup fieldcat of that DROP DOWN field.
    FCAT-DOMNAME = ' '.
    FCAT-CHECKTABLE= '!'.

  • Get selected values from Listbox control

    Hi All,
    I'm still new to SL so please bear with me.
    I have a ListBox being bound with some records from a DB.  Here's the xaml:
    <ListBox x:Name="lstClassSeries" SelectionMode="Multiple" DisplayMemberPath="Description" Grid.Row="11" Grid.Column="1"></ListBox>
    What I need is to get the values of the items that were selected and I can't seem to get it to work.  I've tried looping through the SelectedItems but there's no property for value or text.  I even tried to cast the item as a ListBoxItem but I
    get the following error:
    Unable to cast object of type 'UI.Silverlight.TransactionService.DTODropDown' to type 'System.Windows.Controls.ListBoxItem'.
    How can I get the values of the items selected?
    Thanks

    You're using windows forms style techniques with xaml.
    This is a bad idea.
    You ought to learn MVVM.
    You probably don't think you want to learn it, but trust me on this one.
    Learn MVVM as soon as you can.
    There's a selecteditems collection.
    You have to cast   to listboxitem, it has a content property which you cast to whatever you put in there originally.
    Here's a snippet.
    I have a class foo, load a bunch of them in.  Do stuff. Work out what's selected in the click event of a button.
    public class foo
    public int id {get;set;}
    public string description {get;set;}
    public partial class MainPage : UserControl
    public MainPage()
    InitializeComponent();
    lb.Items.Add(new ListBoxItem{Content=new foo{ id=1, description="a"}});
    lb.Items.Add(new ListBoxItem { Content = new foo { id = 2, description = "b" } });
    lb.Items.Add(new ListBoxItem { Content = new foo { id = 3, description = "c" } });
    private void Button_Click(object sender, RoutedEventArgs e)
    List<foo> selectedfoos = lb.SelectedItems.Cast<ListBoxItem>().Select(x=>x.Content as foo).ToList();
    Hope that helps.
    Recent Technet articles: Property List Editing;
    Dynamic XAML

  • Add List box for one field in ALV GRID

    Hi All,
      I need to add drop down list box for one field in ALV Grid.
      If any body knows, please help.
    Thanks in advance.
    Regards
    Manglesh

    Hi,
    Here is the ex where i have used for date parameter in the sel screen
    type-pools: vrm.
    data: name type vrm_id,
          list type vrm_values,
          value like line of list.
    parameters :    p_date like p_date2
                                  as listbox visible length 15.
    at selection-screen output.
      name = 'P_DATE'.
      value-key = '1'.
      value-text = 'Today'.
      append value to list.
      value-key = '2'.
      value-text = 'Last 7 days'.
      append value to list.
      value-key = '3'.
      value-text = 'Last 30 days'.
      append value to list.
      value-key = '4'.
      value-text = 'Last 90 days'.
      append value to list.
      value-key = '5'.
      value-text = 'Last year'.
      append value to list.
    Call the ''VRM_SET_VALUES' to display the values in Listbox
      call function 'VRM_SET_VALUES'
        exporting
          id     = name
          values = list.
    at selection-screen.
      if sy-ucomm = 'CLI1'.
        sscrfields-ucomm = 'ONLI'(001).
      endif.
      if p_date = '1'.
        p_date11 =  sy-datum .
      elseif p_date = '2'.
        p_date11 = ( sy-datum - 7 ).
      elseif p_date = '3'.
        p_date11 = ( sy-datum - 30 ).
      elseif p_date = '4'.
        p_date11 = ( sy-datum - 90 ).
      elseif p_date = '5'.
        p_date11 = ( sy-datum - 365 ).
      endif.
    Hope this helps u..
    Please reward points if useful.
    Regards,
    Sreenivas

Maybe you are looking for

  • Kernel Panic with 10.6.1 disk utility

    On the kids' iMac (20" unibody) after upgrading to 10.6.1, the boot camp partition would no longer boot (failed with a BSOD in WinXP), so I deleted it with the Boot Camp Assistant. Now, when running Disk Utility, in either "fix" or "verify" disk perm

  • After updating to iOS 8.0.2 iPhone 5 starts eating cell data

    after updating my iphone 5 to ios 8.0.2 iphone eat all my cell data (500m) in one day. all push notifications/background refreshing are off, i always closing apps trying not to loose battery charge. i downloaded few updates by myself, its like 100mb

  • Why can i not get my files? help please!

    I used to have a macbook, running snow leopard, always up to date etc, and it was full of pictures, movies, music, all of which I backed up onto a shiny new time capsule. cut to roughly 6 months later, the hard drive on my macbook dies, but i think i

  • Column RV_TYPE in table CG_REF_CODES in Designer 6i?

    Hi, We moved recently from Designer 6 to Designer 6i. When asked to generate the CG_REF_CODES table, Designer 6i created a table similar to the one we already had under Designer 6 except for column RV_TYPE which is missing. Does anybody know if this

  • TCPDump with multiple interfaces

    Hi, I'm wondering if its possible to use TCPDump to capture traffic (to a file) from all interfaces on a server simulteanously under Solaris 10? From the TCPDump man pages, this seems to be possible under Linux by specifying "-i any" but this doesn't