Combobox on multidimensional array

Combobox on multidimensional array

Postby Marco Turco » Tue Sep 08, 2015 10:57 am

Hi all,
I have a multidimensional array like:

aArray:=array(0,2)
aadd(1,"Marc")
aadd(2,"Luca")
aadd(3,"Jannette")
aadd(4,"Francis")

and I would make a combobox with only the second element list (the names).

Is there a quick way to make this directly into the REDEFINE COMBOBOX command line ?

Thank you in advance
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: Combobox on multidimensional array

Postby Antonio Linares » Tue Sep 08, 2015 5:47 pm

Marco,

Code: Select all  Expand view  RUN
#include "FiveWin.ch"

function Main()

   local aArray := {}
   local oDlg, cName := "Marc"

   AAdd( aArray, { 1, "Marc" } )
   AAdd( aArray, { 2, "Luca" } )
   AAdd( aArray, { 3, "Jannette" } )
   AAdd( aArray, { 4, "Francis" } )

   DEFINE DIALOG oDlg

   @ 1, 1 COMBOBOX cName ITEMS ArrTranspose( aArray )[ 2 ]

   ACTIVATE DIALOG oDlg CENTERED

return nil
regards, saludos

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

Re: Combobox on multidimensional array

Postby Marco Turco » Wed Sep 09, 2015 3:43 pm

Hi Antonio,
it runs. Thank you.

I have just a problem trying to use the ArrTranspose() into the command syntax,
essentially I have to replace the <aItems> with ArrTranspose(<aItems>)[2] but it doesn't runs, sure for a syntax problem. Any ideas ?
Thank you.


#xcommand REDEFINE COMBOLIST [ <oCbx> VAR ] <cVar> ;
[ <items: PROMPTS, ITEMS> <aItems> ] ;
[ ID <nId> ] ;
[ <dlg:OF,WINDOW,DIALOG> <oWnd> ] ;
[ <help:HELPID, HELP ID> <nHelpId> ] ;
[ ON CHANGE <uChange> ] ;
[ VALID <uValid> ] ;
[ <color: COLOR,COLORS> <nClrText> [,<nClrBack>] ] ;
[ <update: UPDATE> ] ;
[ MESSAGE <cMsg> ] ;
[ WHEN <uWhen> ] ;
[ BITMAPS <acBitmaps> ] ;
[ ON DRAWITEM <uBmpSelect> ] ;
[ STYLE <nStyle> ] ;
[ <pict: PICT, PICTURE> <cPicture> ];
[ ON EDIT CHANGE <uEChange> ] ;
=> ;
[ <oCbx> := ] TComboBox():ReDefine( <nId>, bSETGET(<cVar>),;
ArrTranspose(<aItems>)[2], <oWnd>, <nHelpId>, <{uValid}>, [{|Self|<uChange>}],;
<nClrText>, <nClrBack>, <cMsg>, <.update.>, <{uWhen}>,;
<acBitmaps>, [{|nItem|<uBmpSelect>}], <nStyle>, <cPicture>,;
[<{uEChange}>] )
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: Combobox on multidimensional array

Postby Antonio Linares » Wed Sep 09, 2015 5:42 pm

Marco,

Please try this:

ArrTranspose(<aItems>)\[2\]
regards, saludos

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

Re: Combobox on multidimensional array

Postby Marco Turco » Wed Sep 09, 2015 7:55 pm

Great !! Thank you Antonio.
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: Combobox on multidimensional array

Postby cnavarro » Wed Sep 09, 2015 8:09 pm

Marco
I think the solution is:

viewtopic.php?f=3&t=25496&start=0&hilit=arrtranspose

:D :D :D

Sorry,
It's a joke
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 98 guests