可编辑文本框的实现

文本框创建

1、画屏目

         创建一个屏幕,在我们所需要的位置创建一个“自定义控件”,这样屏幕我们就画完了。

2、coding部分

 

首先:对象的创建

         data: g_container type ref to cl_gui_custom-container.   先来定以一个容器

         data: g_editor type ref to cl_gui_textedit.     再在容器里创建一个编辑框

 

第二:对象的实现

         我们重新定义个form来集中实现这部分

         create object g_container

                   exporting 

                            container_name   =  'G_TEXT'      "其中G_TEXT为屏幕的自定义控件名

                   exceptions

                            cntl_error                 = 1

                            cntl_system_error  = 2

                            create_error       = 3

                            lifetime_error      = 3

                            lifetime_dynpro_dynpro_link  = 5.

                   if sy-subrc ne 0.

                            message id sy-msgid type 'E' number sy-msgno

                                     with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

            return.

                   endif.

 

         实现编辑器部分

                   create  object g_editor

                            exporting

                                     parent = g_container      这句话的理解为,其母板为g_container 这个容器

                            wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position  "初始化自定义宽度

 

                            cl_gui_textedit=>wordwrap_off    "初始化时和定义的面板一样大

                            cl_gui_textedit=>wordwrap_at_windowborder

 

                            wordwrap_position = 56   "编辑框单行可输入字符长度

                            wordwrap_to_linerbreank_mode = cl_gui_textedit=>true.

 

去除文本编辑框下面的行、列提示

         call method g_editor->set_statusbar_mod

                   exporting

                            statusbar_mode = cl_gui_textedit=>false.

*去除文本编辑框上的编辑按钮

         call method g_editor->set_toolbar_mode

                   exporting

                            statusbar_mode = cl_gui_textedit=>false.

*  去除文本编辑框上面的编辑按钮

                   call method g_editor->set_toolbar_mode

                            exporting

                                     toolbar_mode = cl_gui_texteidt=>false.

*   内表数据显示到文本框中

data w_it_mytable  type char255 occurs 0.

data w_ih_mytable like line of w_it_mytable.

 

clear: w_ih_mytable , w_it_mytable.

w_ih_mytable = zrdm_support-zanswer.

append w_ih_mytable to w_it_mytable.

 

call method g_editor->set_text_as_r2table

         exporting

                   table = w_it_mytable.

*设置是否可以编辑

call method g_editor->set_readonly_mode

         exporting

                   readonly_mode = cl_gui_textedit=>false.

 

 

第三:获取文本编辑框内容到内表

 

这个我们也可以单独的去写在另外一个form里

types: begin of ty_textline.

         line type char255,

end of ty_textline.

 

data: w_it_mytable type table of ty_textline,

          w_ih_mytble like line of w_it_mytable.

data: w_string type string.

data: ih_support type zrdm_support.

 

call method g_editor->get_text_as_stream  "获取文本编辑狂内容到内表(不用get_text_as_r3table 可以避免换行空格问题)

 importing

         text =  _it_mytable

 exceptions

         error_hp = 1

         error_cnt1_calll_method = 2

others = 3.

if sy-subrc <> 0.

         message Id sy-msgid type 'S' number sy-msgno

         with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 display like 'E'.

         exit.

endif.

 

         

转载于:https://www.cnblogs.com/bailang-LBG/articles/3801111.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值