RE: ListBox and Recno()

Author: Charlie Coleman

Posted: 2005-01-26 at 07:24:28

At 06:44 PM 1/25/2005 -0600, you wrote:

> > Does anyone know how to incorporate the recno() into a list box from the

> > alias that it is pulling from?

> > I need to have the RowsourceType = 2 Alias

> >

> > I have in the Rowsource:

> > certhdr.vcfurno1,loadno1,customer,partno,ponum,htdate,swonum,tokenno

...

If you are locked into using 'Alias' as the .rowsource then I'm not sure.

However, if you change the .rowsource to array you could put the record

number in the array. You could create a subclass of the listbox and give it

an array property.

E.g.

- create subclass of listbox

- add property .aItems[1,1]

- add method .getdata()

- subclass that class into special case - lstCertHdr

- of course, other properties of lstCertHdr could be set up - e.g.

ColumnCount, ColumnWidths, etc

For class lstCertHdr, put code like this in the .GetData() method:

*--- Method: GetData

SELECT vcfurno1, loadno1, customer, partno, ponum, htdate, swonum, recno() ;

FROM CERTHDR ;

INTO ARRAY THIS.aItems

THIS.requery() && I think needed to update listcount, etc

RETURN

The downside of this is you'd have to call the .GetData() method to refresh

the list. So if the data is rapidly changing and you're trying to get a

real-time view that data, this won't work very well IMO.

Hmmm... I was just wondering, if you've using ALIAS as the rowsource, and

if you have SET DELETED OFF (or you know there are no deleted records in

the source table/cursor), and if you are not sorting (and no index is used)

I think the ListIndex value would actually be the same as the recno value.

That's a lot of IFs, but it's something to consider if you're actually

locked into Alias, with real-time data changing....

Lastly, if you're into VFP 8 or later, you might want to consider a Grid.

There are a lot of new features starting in VFP 8 that can make a grid look

a lot like a listbox (better row highlighting behavior, etc).

HTH,

-Charlie

©2005 Charlie Coleman