zoukankan      html  css  js  c++  java
  • pb数据窗口数据输入的下拉选择效果

    1.建立子数据窗口.

    2.在dw_1.editchanged中写如类似下面代码

    if row <=0 then return
    DataWindowChild state_child
    accepttext( )
    string ls_value,partname,cartype
    long findIndex
    if dwo.name = "partno" then
     GetChild("partno", state_child)
     state_child.accepttext( )
     ls_value = trim(getitemstring(row,"partno"))
     state_child.SetTransObject(SQLCA)
     state_child.Retrieve()
     state_child.setfilter( "p_partno like '%"+ls_value+"%' ")
     state_child.filter( )

     end if

    3.在dw_1.itemchanged中写如下代码

    dw_1.event itemfocuschanged( row, dwo)

    因为acceptText()会触犯,itemchanged事件,所以不能在itemchanged事件中写acceptText()

    4.在itemfocuschanged中写如下代码

    if row <=0 then return

    if dwo.name="partno" then
     accepttext( )
     string partno,partname,cartype
     partno = trim(dw_1.getitemstring(row,"partno"));
     
     select p_partname,p_yw into:partname,:cartype from p_partno
     where p_partno=:partno;
     commit;
     
     dw_1.setitem( row, "partname", partname);
     dw_1.setitem( row, "cartype", cartype);
     accepttext( )
    end if

    5.回车键代替Tab件,需要给dw_1建立个用户自定义事件

    6.将使用setitem设置的列tab设置成0

    *********************改进措施*****************************

    申明窗体变量partno_ds
    在open事件中填充partno_ds

    string cmdText
    cmdText="SELECT p_partno Partno,p_partName PartName,p_yw CarType " + &
                   " from p_partno where (p_partno <> '' AND  p_partno is not null and p_partno >'-') " + &
                   " order by  p_partno";

    partno_ds= gf_fill_ds(cmdText);
    调整editchanged事件代码为使用sharedata方式
    if row <=0 then return
    DataWindowChild state_child
    accepttext( )
    string ls_value;
    long findIndex
    if dwo.name = "partno" then
     GetChild("partno", state_child)
     state_child.accepttext( )
     ls_value = trim(getitemstring(row,"partno"))
     partno_ds.sharedata( state_child)
        if  not isnull(ls_value) and trim( ls_value) <> '' then
       state_child.setfilter( "partno like '%"+ls_value+"%' ")
        else
       state_child.setfilter("")
        end if
     state_child.filter( );
      end if
    调整itemfocuschange事件为datastore查找

    if row <=0 then return

    if dwo.name="partno" then
     accepttext( )
     long findIndex
     string partno,partname,cartype
     partno = trim(dw_1.getitemstring(row,"partno"));
     
      findIndex=partno_ds.find( "partno='"+ partno+"'",1, partno_ds.rowcount( ) );
      if(findIndex>=1 ) then
         partname=partno_ds.getitemstring( findIndex,"partname")
       cartype=partno_ds.getitemstring( findIndex, "cartype")
       dw_1.setitem( row, "partname", partname);
         dw_1.setitem( row, "cartype", cartype);
      accepttext( )
         end if

    end if

  • 相关阅读:
    长进程后用电脑发送提示消息到手机微信
    python-openCV 绘制图形
    python调用C++实例:用C++对numpy执行BFS(广度优先搜索)
    numpy中多维数组的绝对索引
    python调用C++ DLL 传参技巧
    React 中常见的动画实现方式
    H5和android原生APP之间的区别
    【转发】三层架构、MVC以及与SSM架构的对应关系(通俗易懂)
    VS code 设置中文后没有反应仍然是英文
    从数据库中获取信息显示在select下拉框中并实现联动
  • 原文地址:https://www.cnblogs.com/wdfrog/p/2239390.html
Copyright © 2011-2022 走看看