Highlighting rows in a DDDW

 

horizontal rule

Back Home Next

Author Aart Onkenhout
Date 12-10-2000

 

When you scroll through a ListBox, the row the cursor is moving over is highlighted. Within a dropdowndatawindow this isn't behaviour that is included. With some scripting however, it is possible.

 

n_cst_dwsrv_dddwscroll is DataWindow service that you can use to scroll through  DropDownDataWindows.

 

Usage

 

There are two  functions you have to call:

 

bullet

of_SetRequestor( Readonly DataWindow idw_Requestor ) Returns Integer. Registers the datawindow requesting the 'service'.

bullet

of_Register( String as_DddwColumn ) Returns Integer. Must be called for each column that has the DDDW-style.

 

In the constructor-event of your DataWindow add the following script:

 

inv_DddwScroll = Create n_cst_dwsrv_dddwscroll

inv_DddwScroll.of_SetRequestor( this )

inv_DddwScroll.of_Register( "dddw_column" )

 

Add an event to your DataWindow, say dwncommand and map this to event-id pbm_command. Add the following script:

 

If notificationcode = 2311 Then
   If IsValid( inv_DddwScroll ) Then
      inv_DddwScroll.Event ue_selectrow( this.GetColumnName(), hwndchild )
   End If
End If

 

The service is now working. The first time you are dropping down the DDDW, PowerBuilder itself selects the current value. After changing the selected row using this service, another row is selected. So, when you drop down the second time, the 'wrong' row is selected.

To take care of this, you can add another event to your DataWindow, namely for the dropdown-event.

Just add an event dwndropdown, map it to pbm_dwndropdown and add the following script to it:

 

If IsValid( inv_DddwScroll ) Then
   inv_DddwScroll.Event ue_preselectrow( this.GetColumnName() )
End If

 

Sample Screen

 

 

Download

 

You can download a (very) small demo-application (PB7) here. Included is a u_dw object with the function you can use when you're using the PFC (it's stand alone, so it's not inherited from pfc_u_dw).

 

Download dddwscroll.pbl