** ListBox column in the XBROWSE

** ListBox column in the XBROWSE

Postby shri_fwh » Tue Dec 08, 2009 10:18 am

** ListBox column in the XBROWSE
When ListBox column get focused in the XBROWSE control and user select one of an Item from the list by pressing
Entry key the control focus is moving to the GET item ( aGET[1] ) whereas the control focus should get next column of the XBROWSE.

Please guide me. I am new to FWH. thanks in advance.

Sample Code here :

procedure billentry

local aGet := array(5)
local oBrw
local aBill := {'Floppy','Pcs', 10, 40}
local cCustName := space(30)

define dailoag oDlg from 0,0 to 24,79 title "List Box Test"


@10,10 get aGet[1] var cCustName pict "@!"

@20,05 XBROWSE oBrw ;
COLUMNS 1,2,3,4,5 ;
HEADERS 'Item','Unit','Qty','Rate';
SIZE 200,100 OF oDlg

WITH OBJECT oBrw:Unit
:nEditType := EDIT_LISTBOX
:aEditTxtList := {"BOX","PCS","DOZ"}
END

oBrw:createfromcode()
// ... some other code to attach to oDlg

active window oDlg on init oBrw:setfoucs()

return nil
Thanks
Shridhar
FWH 19.12, BCC 7 32 bit, MariaDB
shri_fwh
 
Posts: 301
Joined: Mon Dec 07, 2009 2:49 pm

Re: ** ListBox column in the XBROWSE

Postby Antonio Linares » Tue Dec 08, 2009 6:24 pm

Shridhar,

Please try it this way:
Code: Select all  Expand view

   ACTIVATE DIALOG oDlg ON INIT ( oBrw:Setfocus(), ADel( oDlg:aControls, 1 ), .F. )
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41439
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: ** ListBox column in the XBROWSE

Postby shri_fwh » Sat Dec 12, 2009 7:44 am

The same problem facing even after adding this code. I will send the exact source. thanks in advance.
Thanks
Shridhar
FWH 19.12, BCC 7 32 bit, MariaDB
shri_fwh
 
Posts: 301
Joined: Mon Dec 07, 2009 2:49 pm

Re: ** ListBox column in the XBROWSE

Postby nageswaragunupudi » Sat Dec 12, 2009 8:43 am

Mr. Shri

Can you post here simple code, that compiles correctly and runs without runtime errors?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10316
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: ** ListBox column in the XBROWSE

Postby shri_fwh » Mon Dec 21, 2009 7:03 am

Hi Nagesh,

I am sorry too late for post the code. I was busy in office project. Please see below source code.

Problem description : Navigation between GET and TXBRowse control.
In the below code first control focus goes to GET object ( cAccountName ) and it moves to TXBRowse Control.
When user select an item and enter Rate value after the control moves to List Box Column (KG,BOX,PCS). Here when user select an item form ListBox column control focus moves to the GET object ( cAccountName ) where as it should moves to next column of the TXBrowse whic 'Quantity' Column.


Thanks
Shridhar

//-----------------------------------------------------------------------------------------------------------------------//


#include 'fivewin.ch'
#include 'xbrowse.ch'

static aItems := { ;
{ 'Floppy', 10 }, ;
{ 'DVD', 100 }, ;
{ 'Web Cam', 650 }, ;
{ 'HeadSet', 150 }, ;
{ 'USB Drive-4', 400 }, ;
{ 'USB Drive-8', 800 } }

//------------------------------------------------------------------//

function Main()

local oDlg, oBrw, oFont
local aBill := { ;
{ 'Floppy', 10,"BOX", 300, .t., 10 }, ;
{ 'DVD', 100,"PCS", 10, .f., 0 } }
local aoGET := array(10)
local aoSAY := array(10)
LOCAL cAccountName := space(30)
SetGetColorFocus()

DEFINE FONT oFont NAME 'TAHOMA' SIZE 0,-12
DEFINE DIALOG oDlg SIZE 640,400 PIXEL ;
FONT oFont TITLE 'INVOICE'

@20 , 10 Say aoSAY[1] VAR "Account" PIXEL SIZE 40,10 OF oDlg
@20, 55 GET aoGET[1] VAR cAccountName PICTURE "@!" ;
PIXEL size 150, 9 ;
OF oDlg UPDATE



@ 40,10 XBROWSE oBrw SIZE 300,120 PIXEL OF oDlg ;
COLUMNS 1,2,3,4,5,6 ;
HEADERS 'Item', 'Rate', 'Unit', 'Quantity', 'Dis', 'Discount' ;
PICTURES nil, '9,999.99',nil, '9,99,999', nil, '99.99 %' ;
ARRAY aBill ;
CELL LINES FOOTERS FASTEDIT

AEval( oBrw:aCols, { |oCol| oCol:nEditType := EDIT_GET } )
AEval( oBrw:aCols, { |oCol| oCol:bOnChange := { || oBrw:MakeTotals(), oBrw:RefreshFooters() } } )

// Create a caculated column Amount based on Quantity, Value and Discount
oBrw:Amount := { || oBrw:Quantity:Value * oBrw:Rate:Value * ;
( 1 - oBrw:Discount:Value * 0.01 ) }

WITH OBJECT oBrw:Unit
:nEditType := EDIT_LISTBOX
:aEditListTxt := {"BOX","PCS","KG","LTR"}
END

WITH OBJECT oBrw:Amount
:cEditPicture := '9,99,999.99'
:nTotal := 0 // this and next line tell the browse to auto total
:lTotal := .t.
END

WITH OBJECT oBrw:Discount
:bOnChange := { |oCol,uOldVal| oBrw:Dis:Value := ( oCol:Value != 0 ), ;
oBrw:MakeTotals(), oBrw:RefreshFooters() }
:bEditValid := { |oGet,x| x := oGet:oGet:VarGet(), ( x >= 0 .and. x <= 99 ) }
END

// need to add bEditValid for other numeric columns also

WITH OBJECT oBrw:Dis
:SetCheck()
:bOnChange := { |oCol| If( oCol:Value, nil, ;
( oBrw:Discount:Value := 0, oBrw:MakeTotals(), oBrw:Refresh() ) ) }
END

WITH OBJECT oBrw:Item
:nEditType := EDIT_BUTTON
:AddBmpFile( 'e:\fwh\bitmaps\16x16\find2.bmp' )
:nBtnBmp := 1
:bEditBlock := { || SelectItem( oBrw ) }
END

WITH OBJECT oBrw
:nStretchCol := 1
:bPastEof := { || ExtendRow( oBrw ) }
:bChange := { || BrwChangeRow( oBrw ) }
END

oBrw:MakeTotals()
oBrw:CreateFromCode()

ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont

return nil

static function ExtendRow( oBrw )

// Pressing down arrow while on the last row creates a new row
// Even after finishing editing of the last row also creates a new row and ready for edit

if oBrw:nArrayAt == Len( oBrw:aArrayData ) .and. ! Empty( ATail( oBrw:aArrayData )[ 1 ] )
AAdd( oBrw:aArrayData, { '', 0, 0, .f., 0 } )
oBrw:GoDown()
oBrw:GoLeftMost()
endif

return nil

static function BrwChangeRow( oBrw )

if Len( oBrw:aArrayData ) > 1 .and. ;
oBrw:nArrayAt < Len( oBrw:aArrayData ) .and. ;
Empty( ATail( oBrw:aArrayData )[ 1 ] )

// If the newly appended row is empty, delete it

ASize( oBrw:aArrayData, Len( oBrw:aArrayData ) - 1 )
oBrw:Refresh()
endif

return nil

//------------- Incremental Browse for selection of Item --------------- //

static function SelectItem( oBillBrw )

local oDlg, oItems, oFont

DEFINE FONT oFont NAME 'TAHOMA' SIZE 0,-12
DEFINE DIALOG oDlg SIZE 300,300 PIXEL TITLE 'Select Item' FONT oFont

@ 10,10 XBROWSE oItems SIZE 130,100 PIXEL OF oDlg ;
AUTOCOLS ;
HEADERS 'Item', 'Rate' ;
PICTURES nil, '9,999.99' ;
ARRAY aItems ;
AUTOSORT ; // Xbrowse makes incremental seek blocks only when autosort is true
CELL LINES ;
ON DBLCLICK ( SetValues( oItems, oBillBrw ), oDlg:End(), oBillBrw:SetFocus() )

// Following line is what all is needed for incremental browse
// Rest of the work is done by xbrowse

@ 115,10 SAY oItems:oSeek PROMPT oItems:cSeek ;
SIZE 130,10 PIXEL OF oDlg ;
COLOR CLR_RED,CLR_YELLOW UPDATE

@ 130,055 BUTTON 'Select' SIZE 40,12 PIXEL OF oDlg ;
ACTION ( SetValues( oItems, oBillBrw ), oDlg:End(), oBillBrw:SetFocus() )
@ 130,100 BUTTON 'Cancel' SIZE 40,12 PIXEL OF oDlg ACTION oDlg:End()

oItems:bKeyChar := { |n| If( n == 13, ( SetValues( oItems, oBillBrw ), oDlg:End() ), nil ) }
oItems:nStretchCol := 1
oItems:CreateFromCode()

ACTIVATE DIALOG oDlg CENTERED ON INIT ( oItems:GoTop(), oItems:SetFocus(), .f. )
RELEASE FONT oFont

return nil

static function SetValues( oItems, oBillBrw )

local nAt

nAt := AScan( oBillBrw:aArrayData, { |a| Trim( a[ 1 ] ) == Trim( oItems:Item:Value ) } )
if nAt > 0
oBillBrw:nArrayAt := nAt
oBillBrw:Refresh()
Eval( oBillBrw:bChange )
else
WITH OBJECT oBillBrw
:Item:Value := oItems:Item:Value
:Rate:Value := oItems:Rate:Value
if Empty( :Quantity:Value )
:Quantity:Value := 1
endif
:MakeTotals()
:RefreshCurrent()
:RefreshFooters()
END
endif

return nil

//--------------- End of Incremental Browse for Selection ---------------- //
Thanks
Shridhar
FWH 19.12, BCC 7 32 bit, MariaDB
shri_fwh
 
Posts: 301
Joined: Mon Dec 07, 2009 2:49 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 37 guests