下面的脚本在数据窗口的PBm_dwnprocessenter用户事件中编写,用来检查数据窗口中录入数据的各种情况,并执行相应的程序。 1、当返回负值时 肯定某列存在错误,这时既不处理Enter键也不处理Tab键。 2、当返回非负值时 如果是最后的行列则应该在按回车键时插入一行,并使光标定位到新行的第一列上。 如果不是最后行列则应该发送Tab信息,屏蔽Enter键的处理。 脚本如下: If This.AcceptText() < 0 Then //如果不能正确接受用户的输入信息 Return 1 //则不进行按键处理,直接返回 End If If This.GetColumn()=Long(dw_1.Object.DataWindow.Column.Count) Then //如果是最后一列 If This.GetRow() = This.RowCount() Then //并且是在最后一行 This.InsertRow(0) //则增加新行 This.ScrollToRow(This.GetRow() + 1) //并且使之成为当前行 This.SetColumn(1) //并将第一列设置为当前列 Return 1 //然后返回 End If End If Send(Handle(This),256,9,Long(0,0)) //发送处理Tab键的消息 Return 1//忽略回车键的处理
if this.getrow() <= 0 or this.getcolumnname() = "" then return -1 ll_tab = long(this.describe(this.getcolumnname() +".tabsequence")) if ll_tab <= 0 then return -1 for i = 1 to long(this.describe("datawindow.column.count")) if ll_tab < long(this.describe("#"+ string(i) +".tabsequence")) then ll_coltab[upperbound(ll_coltab)+1] = long(this.describe("#"+ string(i) +".tabsequence")) ll_col[upperbound(ll_col)+1] = i end if next if upperbound(ll_coltab) = 1 then li_net = this.setcolumn(ll_col[1]) end if for i = 1 to upperbound(ll_coltab) -1 // 排序 for j = i + 1 to upperbound(ll_coltab) if ll_coltab[i] > ll_coltab[j] then ll_tab = ll_coltab[i] ll_coltab[i] = ll_coltab[j] ll_coltab[j] = ll_tab ll_tab = ll_col[i] ll_col[i] = ll_col[j] ll_col[j] = ll_tab end if next li_net = this.setcolumn( ll_col[i]) if li_net = 1 then exit next if li_net = 1 then long ll_x, ll_width, ll_pos, ll_maxpos
ll_x = long(this.describe("#"+ string(ll_col[i]) +".x")) ll_width = long(this.describe("#"+ string(ll_col[i]) +".width")) ll_maxpos= long(this.describe("DataWindow.HorizontalScrollMaximum")) if (ll_x + ll_width) > this.width then ll_pos = min(ll_maxpos, ll_width + ll_x - this.width +18) end if this.modify("DataWindow.HorizontalScrollPosition='"+ string(ll_pos) +"'") return 1 else return 2 end if