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

  • 相关阅读:
    二分查找 【数组的二分查找】
    二分答案 [TJOI2007]路标设置
    队测 逆序对 permut
    【线段树】 求和
    状压DP Sgu223 骑士
    状压DP Poj3311 Hie with the Pie
    状压DP入门 传球游戏之最小总代价
    状压DP 小W选书籍
    状压DP [Usaco2008 Nov]mixup2 混乱的奶牛
    __gcd()用法
  • 原文地址:https://www.cnblogs.com/wdfrog/p/2239390.html
Copyright © 2011-2022 走看看