Table Control 响应双击事件
一、Table Control 响应双击事件
第一步:属性选择‘响应双击’
第二步:在STATUS里面F2要写成PICK,这样双击的UCOMM就是PICK了
第三步:加上如下代码就可以得到双击的行和列
data: l_row type i.
data: l_field type char30.
CASE OK_CODE.
WHEN ‘PICK’.
get cursor line l_row.
get cursor field l_field.
endcase.
二、Table Control 控制单行是否可编辑
LOOP AT T_DATA
INTO WA_DATA
WITH CONTROL T_CTR1
CURSOR T_CTR1-CURRENT_LINE.
MODULE T_CTR1_GET_LINES. “在这个MODULE里面加如下代码
*&SPWIZARD: MODULE T_CTR1_CHANGE_FIELD_ATTR
ENDLOOP.
**加如下代码
LOOP AT SCREEN .
IF WA_DATA-EBELN IS NOT INITIAL.
SCREEN-INPUT = ‘0’.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
如果采购订单有值,那么这行就不可编辑
三、Table Control控制某一列不显示
DATA: COLS TYPE TABLE OF CXTAB_COLUMN WITH HEADER LINE.
COLS[] = TABCTRL-COLS[]. “TABCTRL是Table Control的名字
LOOP AT COLS.
IF COLS-INDEX = 4 OR COLS-INDEX = 5 OR COLS-INDEX = 8 .
IF G_FLAG NE ‘BT2’.
COLS-INVISIBLE = 1.
ELSE.
COLS-INVISIBLE = 0.
ENDIF.
MODIFY COLS.
ENDIF.
IF COLS-INDEX = 11 OR COLS-INDEX = 9.
IF G_FLAG NE ‘BT1’.
COLS-INVISIBLE = 1. “显示
ELSE.
COLS-INVISIBLE = 0. “不显示
ENDIF.
MODIFY COLS.
ENDIF.
ENDLOOP.
TABCTRL-COLS[] = COLS[].
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/18263.html