• ALV面向对象方法研究:添加双击方法(二)


         继续上篇的内容。

         本文讲解如何添加双击的方法。

         首先程序的开头定义事件类,在ZALV_OO前:   

      CLASS LCL_EVENT_RECEIVER DEFINITION DEFERRED.

    *定义事件
    DATA EVENT_RECEIVER TYPE REF TO LCL_EVENT_RECEIVER.


    * 定义事件属性跟方法
    CLASS LCL_EVENT_RECEIVER DEFINITION.
    PUBLIC SECTION.
    METHODS:
    * 双击方法
    HANDLE_DOUBLE_CLICK
    FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
    IMPORTING E_ROW E_COLUMN.
    ENDCLASS. "LCL_EVENT_RECEIVER DEFINITION

    *----------------------------------------------------------------------*
    * CLASS LCL_EVENT_RECEIVER IMPLEMENTATION
    *----------------------------------------------------------------------*
    * * 双击方法实现
    *----------------------------------------------------------------------*
    CLASS LCL_EVENT_RECEIVER IMPLEMENTATION.
    METHOD HANDLE_DOUBLE_CLICK.
    PERFORM GETRECORD USING E_ROW-INDEX E_COLUMN-FIELDNAME.
    ENDMETHOD. "HANDLE_DOUBLE_CLICK
    ENDCLASS. "LCL_EVENT_RECEIVER IMPLEMENTATION

    *&---------------------------------------------------------------------*
    *& Form GETRECORD
    *&---------------------------------------------------------------------*
    * 具体事件
    *----------------------------------------------------------------------*
    FORM GETRECORD USING E_ROW-INDEX E_COLUMN-FIELDNAME.
    READ TABLE IT_SFLIGHT INDEX E_ROW-INDEX.
    *将行列等信息合并到字符串
    DATA: MSG(100).
    CONCATENATE '行:' E_ROW-INDEX '列名:' E_COLUMN-FIELDNAME INTO MSG.
    CONCATENATE S1 ' CONNID:' IT_SFLIGHT-CONNID INTO MSG.
    CONCATENATE S1 ' CARRID:' IT_SFLIGHT-CARRID INTO MSG.
    MESSAGE MSG TYPE 'I'.
    ENDFORM. "GETRECORD

       然后在ZALV_OO里面刷新ALV前加上此事件:   

    CREATE OBJECT EVENT_RECEIVER.
    SET HANDLER EVENT_RECEIVER->HANDLE_DOUBLE_CLICK FOR GR_ALVGRID.

       如下图:

       

       

  • 相关阅读:
    AtCoder Beginner Contest 167
    AtCoder Beginner Contest 165
    Codeforces Round #732 (Div. 2)
    【贪心 + 模拟】UVA10382 Watering Grass
    【BCC】冗余路径(做法 + 证明)
    数据库作业[定时执行任务]的创建(转)
    SQL数据类型大全 《转自网络》
    C#的OpenFileDialog和SaveFileDialog的常见用法(转)
    团队展示(团队)
    高级软件工程第一次作业--准备
  • 原文地址:https://www.cnblogs.com/saper/p/2380988.html
Copyright © 2020-2023  润新知