Hi All,
I have this list boxes controls that I
copied from the moverlists class in "Solution"
of VFP6.0. I have the following 2 problems when
moving items between the list boxes.

1. It seems I can only display multi columns for
the two list boxes by setting RowSourceType
to 2 or above. Setting RowSourceType to 0
or 1 makes the listbox to display only 1 column.
Since I need to clear the listboxes often so
I'd prefer to set RowSourcetype=0. If I do that
is it still possible to set them to display
multi columns?

2. If I specified RowSourceType to 6 for both
listboxes, The code
SCAN
List.AddItem(table.field)
ENDSCAN
fills both (source and destination) boxes
instead of only the source listbox. Anyone
knows why I am doing wrong here?


I am using VFP6.0 sp5. Thanks for any inputs.

--
jw

Re: Questions about moving items between list boxes by Jack

Jack
Sat Jun 26 18:17:59 CDT 2004

On Sun, 27 Jun 2004 05:37:57 +0800, jw <jw@nospam.com> wrote:

>Hi All,
>I have this list boxes controls that I
>copied from the moverlists class in "Solution"
>of VFP6.0. I have the following 2 problems when
>moving items between the list boxes.
>
>1. It seems I can only display multi columns for
> the two list boxes by setting RowSourceType
> to 2 or above. Setting RowSourceType to 0
> or 1 makes the listbox to display only 1 column.
> Since I need to clear the listboxes often so
> I'd prefer to set RowSourcetype=0. If I do that
> is it still possible to set them to display
> multi columns?

Listboxes with RowSourceType = 0 can have multiple columns. How are
you adding items to the listbox?

>2. If I specified RowSourceType to 6 for both
> listboxes, The code
> SCAN
> List.AddItem(table.field)
> ENDSCAN
> fills both (source and destination) boxes
> instead of only the source listbox. Anyone
> knows why I am doing wrong here?

That makes no sense. The listbox AddItem method only works for
RowSourceType = 0. For type 6 it should have no effect at all (unless
the class you are using overrides that method and does something on
its own).

When you have RowSourceType = 6, do you have different sources for the
two listboxes?


Re: Questions about moving items between list boxes by jw

jw
Sat Jun 26 22:27:53 CDT 2004

Jack,

Thanks for replying.

> Listboxes with RowSourceType = 0 can have multiple columns. How are
> you adding items to the listbox?

This is how I add the items. I have a SQL SELECT
command right before this following code. Can you
show me how I can display multi columns for
RowSuorceType = 0?

SCAN
LstSource.AddItem(CursorName.field1)
ENDSCAN


> That makes no sense. The listbox AddItem method only works for
> RowSourceType = 0. For type 6 it should have no effect at all (unless
> the class you are using overrides that method and does something on
> its own).
>
> When you have RowSourceType = 6, do you have different sources for the
> two listboxes?

No I only specified the source for the source list box.
Guess I shouldn't use type 6 in my case, right?

--
jw


Re: Questions about moving items between list boxes by jw

jw
Sat Jun 26 22:32:40 CDT 2004

One other thing,

I also have rowsource = 'field1,field2,field3'
and column count = 3 for BOTH list boxes.
Wondering if this would contribute the error.

Thanks

--
jw


Re: Questions about moving items between list boxes by Jack

Jack
Sun Jun 27 00:07:48 CDT 2004

On Sun, 27 Jun 2004 11:27:53 +0800, jw <jw@nospam.com> wrote:

>Jack,
>
>Thanks for replying.
>
> > Listboxes with RowSourceType = 0 can have multiple columns. How are
> > you adding items to the listbox?
>
>This is how I add the items. I have a SQL SELECT
>command right before this following code. Can you
>show me how I can display multi columns for
>RowSuorceType = 0?
>
> SCAN
> LstSource.AddItem(CursorName.field1)
> ENDSCAN

LstSource.RowSourceType = 0
nX = 0
SCAN
nX = nX + 1
LstSource.Additem(CursorName.field1, nX, 1)
LstSource.Additem(CursorName.field2, nX, 2)
LstSource.Additem(CursorName.field3, nX, 3)
ENDSCAN

If you want to use RowSourceType = 6 instead:

SELECT field1, field2, field3 FROM sometable INTO CURSOR lstcurs
LstSource.RowSourceType = 6
LstSource.RowSource = "lstcurs.field1,field2,field3"

Another possibility:

LstSource.RowSourceType = 3
LstSource.RowSource = "SELECT field1, field2, field3 FROM sometable
INTO CURSOR " + SYS(2015)


Re: Questions about moving items between list boxes by jw

jw
Mon Jun 28 04:04:26 CDT 2004

Helli Jack,

I'm still not able to get it working,
It errors out at the line where I mark
with arrow. Apparently it doesn't like
adding more than 1 items in the scan loop.
The error message is:
"Function argument value, type, or count is invalid"

Here's part of my code:

*--------------------------
SELECT doc_no, amount, doc_date FROM sometable INTO CURSOR lstcurs

WITH THISFORM.MoverList1
.lstSource.ColumnCount = 3
.lstSource.ColumnWidths = "60, 70, 80"
.lstSource.RowSourceType = 0

.lstSelected.ColumnCount = 3
.lstSelected.ColumnWidths = "60, 70, 80"
.lstSelected.RowSourceType = 0

.lstSource.RowSource = "lstCurs.doc_no, amount, doc_date"
.lstSelected.RowSource = "lstCurs.doc_no, amount, doc_date"
.lstSelected.Clear()
.lstSource.Clear()
nX = 0
SCAN
nX = nX + 1
.lstSource.Additem(lstCurs.doc_no, nX, 1)
.lstSource.Additem(lstCurs.amount, nX, 2) && <-- Error here.
.lstSource.Additem(lstCurs.doc_date, nX, 3)
ENDSCAN
ENDWITH
*--------------- End of code -----------------

However, I could get it to work, sort of,
making these changes:

.lstSource.RowSourceType = 2
scan
SCAN
.lstSource.Additem(doc_no)
ENDSCAN

After the change all 3 items do show up on
the 3 columns in the source list. But when
they get selected, only the first column is
showing on the selected list, the rest 2 cols
are blank.
This is a class I take from the sample.vcx and
I don't know how to alter the code to make all
3 columns appear on the select list.

I would appreciate any suggestions/directions.
Thank you.

--
jw


Re: Questions about moving items between list boxes by jw

jw
Mon Jun 28 09:14:04 CDT 2004

Hello,

I have further changed my code as follows and
got it working for rowsourcetype=0

nX = 0
SCAN
nX = nX + 1
.lstSource.AddItem(LstCurs.doc_no )
.lstSource.List[nX, 2] = ALLTRIM(STR(LstCurs.amount))
.lstSource.List[nX, 3] = DTOC(LstCurs.sdate)
ENDSCAN

Now all there is left to find out is to find a way to
make the 3 columns in the Selected listbox appear
like the source. Currently it only displays the first
column, and the rest 2 are blank columns.

Ideas anyone?

--
jw



Re: Questions about moving items between list boxes by Stefan

Stefan
Mon Jun 28 14:39:01 CDT 2004

Your code works for me, as long as listbox.ColumnCount = 3

However, isn't Jack's other suggestion easier?
LstSource.RowSourceType = 3
LstSource.RowSource = "SELECT field1, field2, field3 " + ;
"FROM sometable INTO CURSOR " + SYS(2015)
You could get rid of the entire Scan/Endscan that way


-Stefan

"jw" <jw@nospam.com> schrieb im Newsbeitrag
news:uqF$IpRXEHA.3596@tk2msftngp13.phx.gbl...
> Hello,
>
> I have further changed my code as follows and
> got it working for rowsourcetype=0
>
> nX = 0
> SCAN
> nX = nX + 1
> .lstSource.AddItem(LstCurs.doc_no )
> .lstSource.List[nX, 2] = ALLTRIM(STR(LstCurs.amount))
> .lstSource.List[nX, 3] = DTOC(LstCurs.sdate)
> ENDSCAN
>
> Now all there is left to find out is to find a way to
> make the 3 columns in the Selected listbox appear
> like the source. Currently it only displays the first
> column, and the rest 2 are blank columns.
>
> Ideas anyone?
>
> --
> jw
>
>


Re: Questions about moving items between list boxes by jw

jw
Mon Jun 28 14:59:13 CDT 2004

Stefan, rowsourcetype=3 just wouldn't work
for me, and I don't know why. Setting rowsourcetype
to anything greater than the value of 1 will make
the selected records to populate in both listboxes
at the same time. I tried Rowsoucetype=0 and that
works for me. I have too little time left to
investigate the reason. Now I have to try digging
into the code and change that a bit to make the
3-column-move work. Sigh!

Thanks for the reply.

--
jw






Stefan Wuebbe wrote:
> Your code works for me, as long as listbox.ColumnCount = 3
>
> However, isn't Jack's other suggestion easier?
> LstSource.RowSourceType = 3
> LstSource.RowSource = "SELECT field1, field2, field3 " + ;
> "FROM sometable INTO CURSOR " + SYS(2015)
> You could get rid of the entire Scan/Endscan that way
>
>
> -Stefan
>
> "jw" <jw@nospam.com> schrieb im Newsbeitrag
> news:uqF$IpRXEHA.3596@tk2msftngp13.phx.gbl...
>
>>Hello,
>>
>>I have further changed my code as follows and
>>got it working for rowsourcetype=0
>>
>> nX = 0
>> SCAN
>> nX = nX + 1
>> .lstSource.AddItem(LstCurs.doc_no )
>> .lstSource.List[nX, 2] = ALLTRIM(STR(LstCurs.amount))
>> .lstSource.List[nX, 3] = DTOC(LstCurs.sdate)
>> ENDSCAN
>>
>>Now all there is left to find out is to find a way to
>>make the 3 columns in the Selected listbox appear
>>like the source. Currently it only displays the first
>>column, and the rest 2 are blank columns.
>>
>>Ideas anyone?
>>
>>--
>>jw
>>
>>
>
>


Re: Questions about moving items between list boxes by Stefan

Stefan
Tue Jun 29 03:16:50 CDT 2004


"jw" <jw@nospam.com> schrieb im Newsbeitrag
news:Od1VAqUXEHA.1152@TK2MSFTNGP09.phx.gbl...
> Stefan, rowsourcetype=3 just wouldn't work
> for me, and I don't know why. Setting rowsourcetype
> to anything greater than the value of 1 will make
> the selected records to populate in both listboxes
> at the same time. I tried Rowsoucetype=0 and that
> works for me. I have too little time left to
> investigate the reason. Now I have to try digging
> into the code and change that a bit to make the
> 3-column-move work. Sigh!

I see, here is the runnable test.prg which "works for me"


Good luck
-Stefan

* listbox_scan_additem.prg
LOCAL nx

&& example data
CREATE CURSOR lstcurs (doc_no C(10), amount I, sdate D)
INSERT INTO lstcurs VALUES ("one", 5, DATE())
INSERT INTO lstcurs VALUES ("two", 7, DATE()-10 )

WITH _screen
IF PEMSTATUS(_screen,'lstSource',5)
.RemoveObject('lstSource')
ENDIF
.AddObject('lstSource','Listbox')
.lstSource.Width = 150
.lstSource.ColumnCount = 3
.lstSource.ColumnWidths = '30,10,50'
.lstSource.Visible = .T.

nX = 0
SCAN
nX = nX + 1
.lstSource.AddItem(LstCurs.doc_no )
.lstSource.List[nX, 2] = ALLTRIM(STR(LstCurs.amount))
.lstSource.List[nX, 3] = DTOC(LstCurs.sdate)
ENDSCAN
ENDWITH
*