แค่เว็บๆหนึ่ง ! ที่อยากเก็บประสบการณ์
Home
 

PowerBuilder กดปุ่ม enter แล้วให้ ย้ายไปอีก field

By default, pressing the ENTER key changes the focus to the same column in row below it, if there is any row below it. In a typical data-entry screen in the industry, pressing the ENTER moves the focus to the next field in the same row. Let’s now add this functionality to the DataWindow. Declare a user-defined event ue_ProcessEnter and map pbm_dwnProcessEnter event id to it and write the following code:

 

// Object: dw_product
// Event:  Ue_ProcessEnter
long ll_CurrentRow
int  li_ColCount, li_ColNo
int i, li_TabOrder, li_Protection
boolean lb_IsColumnSet
li_ColCount = integer(this.object.DataWindow.Column.Count )
li_ColNo    = this.GetColumn()
IF  li_ColNo < li_ColCount THEN
   this.SetColumn( li_ColNo + 1 )
   FOR i = ( li_ColNo + 1 ) TO li_ColCount
       li_TabOrder = &
          integer( this.Describe( "#" + String(i) + & 
                   ".TabSequence" ))
       li_Protection = &
          integer( this.Describe( "#" + String(i) + &
                   ".Protect" ))
       IF li_TabOrder > 0 AND li_Protection = 0 THEN
          this.SetColumn( i )
          lb_IsColumnSet = TRUE
          EXIT
       END IF
   NEXT
END IF
// No non-protected, non-zero tab order column found.
IF NOT lb_IsColumnSet THEN
   ll_CurrentRow = this.GetRow()
   // Let's try in the next row, if there is one.
   if ll_CurrentRow = this.RowCount() THEN return 1
   // There is a row.
   FOR i = 1 TO li_ColCount
       li_TabOrder = &
          integer( this.Describe( "#" + String(i) + &
                 ".TabSequence" ))
       li_Protection = &
          integer( this.Describe( "#" + String(i) + &
                 ".Protect" ))
       IF li_TabOrder > 0 AND li_Protection = 0 THEN
          // Column is found. Let's set the focus and 
          //        scroll to that row.
          this.SetRow( ll_CurrentRow + 1 )
          this.SetColumn( i )
          this.ScrollToRow( ll_CurrentRow )
          EXIT
       END IF
   NEXT
END IF

 

ที่มา  : http://powerbuilder.hyderabad-colleges.com/Advanced-PowerBuilder-8-11-300.html

Off 

January 3, 2014 This post was written by Categories: เรื่องเล่ารายวัน No comments yet


Top