回 帖 发 新 帖 刷新版面

主题:数据窗口的问题请教

在数据窗口内选中一列后它会自动加亮显示,请问怎么去除该效果

回复列表 (共3个回复)

沙发

如何在DDDW中实现当前高亮行随鼠标移动 
 
一、所有对DDDW的操作都通过触发pbm_command事件完成
1、在PB的用户事件中,大多数事件对应的Windows 事件都有两个参数:lparam 和 wparam,而在PB5.0中,pbm_command没有参数,但可以通过message对象的两个属性取得Windows事件对应的Event ID,这两个属性就是: LongParm 和 WordParm。
LongParm 包含DDDW的Handle,用intLow()可取得其Handle
WordParm 包含对DDDW的操作,用intHigh()可取得其Event ID

2、在PB6.5中,pbm_command带3个参数,其中hwndchild(long)与notificationcode(unsignedinteger)即DDDW的Handle和Event ID。

二、DDDW 的Event ID 列表:

Event Event ID 
Clicked 1281 
RowFocusChanged 2048 
RightMouseButtonDown 2314 
Left Button Up 2313 
Retreive End 769 
MouseMove 2311 
RowFocusChanged 2048 
鼠标点击滚动条上下按钮:PageUp/PageDown 2339 
...   

根据上述列表,就可以在 pbm_command 事件中判断对DDDW做了何种操作:

三、举例:在DDDW中实现当前高亮行随鼠标移动
DataWindowChild ldwc_Child
String ls_Pointer
Long ll_Row

GetChild( "dept_id", ldwc_Child ) // Replace the column name "dept_id" as you needed

IF hwndchild = Handle( ldwc_child ) THEN
if notificationcode = 2311 then //DDDW的mousemove事件
//得到鼠标所在行
ls_Pointer = ldwc_Child.GetObjectAtPointer()
ll_Row=Long( Mid( ls_Pointer, Pos( ls_Pointer, "~t" ) + 1 ))
//移到鼠标所在行
IF ldwc_Child.GetRow() <> ll_Row AND ll_Row > 0 THEN
ldwc_Child.ScrollToRow( ll_Row )
END IF
end if
END IF 
 

板凳

使用selectrow()函数也可实现.

Description 

Highlights or removes highlights from rows in a DataWindow control or DataStore. You can select all rows or a single row. SelectRow does not affect which row is current. It does not select rows in the database.

Controls 

DataWindow type    Method applies to
PowerBuilder    DataWindow control, DataWindowChild object, DataStore object
Web ActiveX    DataWindow control, DataWindowChild object
Syntax 
PowerBuilder  

integer dwcontrol.SelectRow ( long row, boolean select )

Web ActiveX  

number dwcontrol.SelectRow ( number row, boolean select ) 

Argument    Description
dwcontrol    A reference to a DataWindow control, DataStore, or child DataWindow.
row    A value identifying the row you want to select or deselect. Specify 0 to select or deselect all rows.
select    A boolean value that determines whether the row is selected or not selected:?TRUE ?Select the row(s) so that they are highlighted.?FALSE ?Deselect the row(s) so that they are not highlighted.
Return value 

Returns 1 if it succeeds and -1 if an error occurs. If any argument's value is NULL, in PowerBuilder and JavaScript the method returns NULL.

Usage 

If a row is already selected and you specify that it be selected (boolean is TRUE), it remains selected. If a row is not selected and you specify that it not be selected (
boolean is FALSE), it remains unselected.


PowerBuilder  This statement selects the fifteenth row in dw_employee:

dw_employee.SelectRow(15, TRUE)

As the script for a DataWindow's Clicked event, this example removes highlighting from all rows and then highlights the row the user clicked.
Row is an argument passed to the event script:

This.SelectRow(0, FALSE)

This.SelectRow(row, TRUE)

3 楼

是列的加亮取消,不是行哦

我来回复

您尚未登录,请登录后再回复。点此登录或注册