设置Detail域的背景色之后的一个奇怪问题

jjoulejcc 2013-03-14 09:19:08
开发环境:PB11.5 Build 3127

我是想实现这样的效果,当前选中行的颜色为红色,非选中行为白色。在Grid风格的数据窗口对象的Detail域背景色表达式中写如下代码:IF( GetRow() = CurrentRow(), RGB(255, 0, 0), RGB(255, 255, 255) )
OK,效果是实现了,鼠标单击一起正常,但是调用dw.SetRow(ll_RowNum)设置当前行后,数据窗口中的焦点并没有切换到ll_RowNum这一行上,但是调用dw.GetRow()后返回值又确实是ll_RowNum。调用一下dw.SetRedraw(True)或者MessageBox(...)之类的,行焦点就马上切换到ll_RowNum上了。但是这时在数据窗口中按上下方向键也没有反应,即使调用了dw.SetRedraw(True)。
不知道这是不是DW的一个BUG,有遇到类似情况的朋友说说你们是怎么解决的。
...全文
1123 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
winstonsu 2013-03-31
  • 打赏
  • 举报
回复
引用 7 楼 jjoulejcc 的回复:
引用 5 楼 swtao 的回复:1、dw_1.setrow(ll_RowNum): 选中行的颜色的脚本会起作用; 2、如果数据多,出了滚动条,要想跳到ll_RowNum行上,加dw_1.scrolltorow(ll_RowNum); 3、焦点回到dw上,dw_1.setfocus( ) 就是第1条没有起作用,我是把表达式写在Detail域上的,不是列上的,所以……
把你的完整代码贴出来。 IF(GetRow() = CurrentRow(), RGB(255, 0, 0), RGB(255, 255, 255)) 肯定没问题,11.5的各个小版本我都用过。 但是以下情况例外:所有的列的protect都设为1,或者taborder都设为0,setrow之后颜色不会变,鼠标随便点哪一下才会变,但是getrow返回行号是正确的。
jjoulejcc 2013-03-31
  • 打赏
  • 举报
回复
引用 9 楼 swtao 的回复:
引用 7 楼 jjoulejcc 的回复:引用 5 楼 swtao 的回复:1、dw_1.setrow(ll_RowNum): 选中行的颜色的脚本会起作用; 2、如果数据多,出了滚动条,要想跳到ll_RowNum行上,加dw_1.scrolltorow(ll_RowNum); 3、焦点回到dw上,dw_1.setfocus( ) 就是第1条没有起作用,我是把表达……
嗯,是的,就是所有列的tab order是0,没搞清楚是为什么
jjoulejcc 2013-03-30
  • 打赏
  • 举报
回复
引用 6 楼 smitxx 的回复:
引用 3 楼 jjoulejcc 的回复:引用 1 楼 smitxx 的回复:dw.SetRow(ll_RowNum) 只是设置了getrow,但并没有设置 CurrentRow(),getrow()与currentrow()是不一样的 你看帮助呢,dw.SetRow()就是设置当前行的: Sets the current row in a DataWindow co……
GetRow(): 1.Reports the number of the current row in a DataWindow control or DataStore object. 2.The current row is not always a row displayed on the screen. For example, if the cursor is on row 7 column 2 and the user uses the scroll bar to scroll to row 50, the current row remains row 7 unless the user clicks row 50. CurrentRow(): 1.Reports the number of the current row (the row with focus). 2.The current row is not always a row displayed on the screen. For example, if the cursor is on row 7 column 2 and the user uses the scroll bar to scroll to row 50, the current row remains row 7 unless the user clicks row 50. 帮助里就是这样写的,你说说看,GetRow()和CurrentRow()到底哪里不一样; 如果这两个东西不一样,那我们常用的这个代码是不是有问题呢:IF( GetRow() = CurrentRow(), true, false ); 就算你说的不一样,你看该怎么解决这个问题?表达式写在列上可以,写在Detail域就不可以了
jjoulejcc 2013-03-30
  • 打赏
  • 举报
回复
引用 5 楼 swtao 的回复:
1、dw_1.setrow(ll_RowNum): 选中行的颜色的脚本会起作用; 2、如果数据多,出了滚动条,要想跳到ll_RowNum行上,加dw_1.scrolltorow(ll_RowNum); 3、焦点回到dw上,dw_1.setfocus( )
就是第1条没有起作用,我是把表达式写在Detail域上的,不是列上的,所以才感觉奇怪。另外我测试的时候,设置的行号都是不用拖动滚动条就可见的,不存在ScrollToRow的问题。
smitxx 2013-03-22
  • 打赏
  • 举报
回复
引用 3 楼 jjoulejcc 的回复:
引用 1 楼 smitxx 的回复:dw.SetRow(ll_RowNum) 只是设置了getrow,但并没有设置 CurrentRow(),getrow()与currentrow()是不一样的 你看帮助呢,dw.SetRow()就是设置当前行的: Sets the current row in a DataWindow control or DataStore. ……
也请你看一下currentrow的帮助。
winstonsu 2013-03-22
  • 打赏
  • 举报
回复
1、dw_1.setrow(ll_RowNum): 选中行的颜色的脚本会起作用; 2、如果数据多,出了滚动条,要想跳到ll_RowNum行上,加dw_1.scrolltorow(ll_RowNum); 3、焦点回到dw上,dw_1.setfocus( )
jjoulejcc 2013-03-22
  • 打赏
  • 举报
回复
引用 2 楼 sjlion 的回复:
正常情况下是不会的。不知道你是否用了什么界面框架,比如advgui什么的。看你描述的,好像是重绘的进程被阻塞了,而且dw的焦点也丢了。你重建一个窗口,一个dw,其他什么代码都不放,只验证当前行的值看下
没有用什么框架,都是自己写的,所以才感觉奇怪。你不信可以测试下,就是设置Detail域的背景色,然后用dw.SetRow(),看看他起作用没有
jjoulejcc 2013-03-22
  • 打赏
  • 举报
回复
引用 1 楼 smitxx 的回复:
dw.SetRow(ll_RowNum) 只是设置了getrow,但并没有设置 CurrentRow(),getrow()与currentrow()是不一样的
你看帮助呢,dw.SetRow()就是设置当前行的: Sets the current row in a DataWindow control or DataStore.
sjlion 2013-03-19
  • 打赏
  • 举报
回复
正常情况下是不会的。不知道你是否用了什么界面框架,比如advgui什么的。看你描述的,好像是重绘的进程被阻塞了,而且dw的焦点也丢了。你重建一个窗口,一个dw,其他什么代码都不放,只验证当前行的值看下
smitxx 2013-03-18
  • 打赏
  • 举报
回复
dw.SetRow(ll_RowNum) 只是设置了getrow,但并没有设置 CurrentRow(),getrow()与currentrow()是不一样的

609

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder DataWindow
社区管理员
  • DataWindow社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧