listbox recno() display

listbox recno() display

Postby brewster » Fri Dec 14, 2012 8:55 pm

Hello,

I am trying to implement a recno() indicator for the listbox code below.
By moving the row selection up or down it would display the related .dbf recno() in the dialog.
I gather some sort of bSkip mechanism is required.
I do not know the proper coding / syntax to accomplish the task.


@ 1, 1 LISTBOX oLbx ;
FIELDS TM->Shp_dte, TM->org, TM->DrpA, TM->DrpB ,;
TM->DrpC, TM->DrpD, TM->Drvr, TM->Notes ;
HEADERS "Ship Date", "Orgin", "A", "B", "C", "D", "DR","Notes" ;
FIELDSIZES 60, 45, 45, 45, 45, 45 , 40, 50 ;
SIZE 284, 137 OF oDlg


// possible ??
// space(5)+ {|nRecs|,dbskipper()}
//trans(oTmd:recno(),'99,999') +;
// ' / '+trans(oTmd:lastrec(),'99,999') OF oDlg

// possible
//{|nRecs|,oLbx:keyno() }

Any help, much appreciated.

Bruce S.

FW 6/12
Harbour v3.1 Rev 17222
ilink32 6.21
brewster
 
Posts: 43
Joined: Wed Jun 20, 2012 4:07 am

Re: listbox recno() display

Postby Enrico Maria Giordano » Sat Dec 15, 2012 9:41 pm

Try using ON CHANGE clause.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: listbox recno() display

Postby brewster » Sun Dec 16, 2012 2:57 pm

Enrico,
Thanks for your reply.
I need a little bit more.

So I try :

local nRecno
local bSkip

use TMD alias TM
//database oTm not using database statement, just the alias

@ 1, 1 LISTBOX oLbx ;
FIELDS TM->Shp_dte, TM->org, TM->DrpA, TM->DrpB ,;
TM->DrpC, TM->DrpD, TM->Drvr, TM->Notes ;
HEADERS "Ship Date", "Orgin", "A", "B", "C", "D", "DR","Notes" ;
FIELDSIZES 60, 45, 45, 45, 45, 45 , 40, 50 ;
ON CHANGE ( have tried all the syntax below and more ) ;
SIZE 284, 137 OF oDlg

//ON CHANGE oLbx:bSkip:= {|nRecno| , (dbskipper(TM->recno() ) ) } ;
//ON CHANGE {|nRecno|, oLbx:recno() } ;
//ON CHANGE oLbx: {|nRecno|, TM->recno() } ;

frustration is just clouding it up now
an actual ON CHANGE statement with proper syntax wold be greatly appreciated

Thanks,
Bruce
brewster
 
Posts: 43
Joined: Wed Jun 20, 2012 4:07 am

Re: listbox recno() display

Postby MarcoBoschi » Sun Dec 16, 2012 3:17 pm

Bruce,
try this

Code: Select all  Expand view
#include "fivewin.ch"
FUNCTION MAIN
local oDlg
local oLbx


use customer

DEFINE DIALOG oDlg FROM 0 , 0 TO 300 , 300  PIXEL

@ 1, 1 LISTBOX oLbx ;
FIELDS field->first, field->last , STR(recno(),4) ;
HEADERS "First", "Last", "Recno"  ;
FIELDSIZES 40 , 40 , 40  OF oDlg  SIZE 150 , 150

ACTIVATE DIALOG oDlg CENTER

RETURN  NIL
 


If You substitute STR(recno(),4) With recno() You do not see record number but empty column
Do not ask me WHY!

bye now
marco
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: listbox recno() display

Postby Enrico Maria Giordano » Sun Dec 16, 2012 3:24 pm

Bruce,

if you want to show the record number in a column then follow Marco's advice. If you want to show the record number in a GET while moving the record pointer then use something like

... GET oGet Var cVar

...

ON CHANGE ( cVar := LTRIM( STR( RECNO() ) ), oGet:Refresh() )

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: listbox recno() display

Postby Enrico Maria Giordano » Sun Dec 16, 2012 3:27 pm

MarcoBoschi wrote:If You substitute STR(recno(),4) With recno() You do not see record number but empty column
Do not ask me WHY!


Because TWBrowse takes data numbers as bitmaps handles. That's how it displays bitmaps inside its cells.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: listbox recno() display

Postby brewster » Sun Dec 16, 2012 7:13 pm

Marco / Enrico ,

Thanks for your tips/advice. I got it working.

One final question.

Within the dialog I'm using for this listbox, I have - Search, OK, and Cancel buttons.

When returning from the search function(), I have to click on the data portion of the listbox to get its "focus" back
to a highlighted data record.

I gather there is a FW setfocus function(), when coming out of my search function(), it would automatically return to the
highlighted record.

Many thanks,
Bruce
brewster
 
Posts: 43
Joined: Wed Jun 20, 2012 4:07 am

Re: listbox recno() display

Postby Enrico Maria Giordano » Sun Dec 16, 2012 7:15 pm

As simple as oBrw:SetFocus(). :-)

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8713
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 118 guests