I'm trying to convert an old inventory management source where I used a listbox.
The substantial problem is that the first two columns (CVEPRO,DESCRI) must be inverted online according to the number corresponding to the combobox.
The combobox is connected to Xbrowse because I use it to search fields.
Practically it happens that the columns don't change and if I insert the option :SetMultiSelectCol() adding a column at the beginning it undoes the other columns and I don't know how to do it.
you can see that the fourth column is repeated the third why ?
I did a small test to show the problem, send me your mailbox where I can send the dbf to try with the test
- Code: Select all Expand view RUN
#include "FiveWin.ch"
static oWinMain,oT
static oControl
function Main()
*oControl := TDatabase():Open(,"Control" ,"DBFCDX", .t.)
* xbrowser oControl
DEFINE WINDOW oWinMain TITLE "Test" MDI ;
MENU BuildMenu()
ACTIVATE WINDOW oWinMain
return nil
function BuildMenu()
local oMenu
MENU oMenu
MENUITEM "Test"
MENU
MENUITEM "Articoli" ACTION Articoli()
ENDMENU
oMenu:AddMdi()
ENDMENU
return oMenu
Function Articoli()
local nCla:=1
local oFont1
local cHead1:=IF(nCla=1,"Codice","Descrizione")
local cHead2:=IF(nCla=1,"Descrizione","Codice")
local nS1:= IF(nCla=1,125,365)
local nS2:= IF(nCla=1,365,125)
local oArticoli
local oLbx,aCols
local oBar,oWinArticoli,oTabs
local cSeek:=Space(100)
local oGet
local oSay:=array(4)
local cOrder := ""
IF oWinArticoli == nil
oT:= MA_130():New()
oArticoli := TCatalogo():New()
oArticoli:SetOrder(1 )
oArticoli:GoTop()
cTitolo := "Anagrafica articoli"
/* aCols := { ;
{ "" , cHead1 ,, nS1, },;
{ "MR" , "MR" ,, 50, },;
{ "" , cHead2 ,, nS2, },;
{ "" , "" ,, 50, },;
{ "Esistenza", "" ,, 50, }}
*/
aCols := { ;
{ "CVEPRO" , "Codice" ,, 100, },;
{ "MR" , "MR" ,, 50, },;
{ "DESCRI" , "Descrizione" ,, 150, },;
{ "", "" ,, 50, },;
{ "Esistenza", "" ,, 50, }}
DEFINE WINDOW oWinArticoli MDICHILD ;
FROM 0, 0 TO 24, 79 ;
TITLE cTitolo ;
of oWinMain
DEFINE FONT oFont1 NAME "Tahoma" SIZE 0, -12 BOLD
DEFINE BUTTONBAR oBar TOP _3D OF oWinArticoli
DEFINE BUTTON RESOURCE "Nuevo" NOBORDER OF oBar ;
TOOLTIP "aggiungi" ;
ACTION NIL
DEFINE BUTTON RESOURCE "editar" NOBORDER OF oBar ;
TOOLTIP "Editar" ;
ACTION NIL
DEFINE BUTTON RESOURCE "Elimin" NOBORDER OF oBar ;
TOOLTIP "Eliminar" ACTION NIL
@ 4,231 say oSay[1] Prompt "Cerca :" SIZE 46,12 PIXEL OF oBar FONT oFont1
@ 4,435 say oSay[2] Prompt "in" SIZE 40,12 PIXEL OF oBar FONT oFont1
@ 2, 280 GET oGet VAR cSeek SIZE 150,22 PIXEL OF oBar ;
BITMAP "ELIMINA" ACTION (cSeek := Space( 100 ),;
oLbx:Seek( "" ), oLbx:refresh(), oGet:refresh())
oGet:lBtnTransparent :=.t.
//Tabs
@ 00, 00 TABS oTabs OF oWinArticoli ;
PROMPT "Codice", "Descrizione" ;
COLORS GetSysColor(13), GetSysColor(14) ;
ACTION ( Orden(oTabs,oArticoli,oLbx,oWinArticoli),;
oLbx:oSortCbx:set(oTabs:nOption) )
//Xbrowse
@ 0,0 XBROWSE oLbx OF oWinArticoli ;
DATASOURCE oArticoli COLUMNS aCols ;
AUTOSORT ;
NOBORDER CELL LINES
WITH OBJECT oLbx
:nRowHeight := 30
:l2007 := .F.
:l2015 := .T.
:nColDividerStyle := LINESTYLE_LIGHTGRAY
:nRowDividerStyle := LINESTYLE_LIGHTGRAY
:nStretchCol := STRETCHCOL_WIDEST
:lAllowRowSizing := .F.
:lAllowColSwapping := .F.
:lAllowColHiding := .F.
:nRecSelColor := nRgb( 245,244,234)
:lIncrFilter := .t.
:bOnSort := { |b,oCol| oLbx:Seek( "" ), ;
oLbx:cFilterFld := oCol:cExpr, ;
oLbx:SetFocus() }
* :bClrStd := { || { CLR_BLACK, If( oLbx:oCol( 1 ):Value, 0x80ffff, CLR_WHITE ) } }
:bClrHeader := {|| { ,nRgb( 245,244,234) } }
:bClrFooter := {|| { ,nRgb( 245,244,234) } }
:lDrawBorder := .t.
:lHScroll := .f.
:SetMultiSelectCol()
:oSeek := oGet
:nMarqueeStyle := MARQSTYLE_HIGHLWIN7
WITH OBJECT oLbx:aCols[ 2 ]
:cHeader := cHead1
:nWidth:= nS1
:bEditValue := { || Desp_Fld1(oLbx:oSortCbx:nat,oArticoli) }
END
WITH OBJECT oLbx:aCols[ 3 ]
:cHeader := cHead2
:nWidth:= nS2
:bEditValue := { || Desp_Fld2(oLbx:oSortCbx:nat,oArticoli) }
END
WITH OBJECT oLbx:aCols[ 5 ]
:AddResource("I_Nor")
:AddResource("I_Min")
:AddResource("C_Pal")
:AddResource("I_Lot")
:AddResource("I_Gpo")
:AddResource("I_Grd")
:bBmpData := { || Desp_Mar(oArticoli) }
END
WITH OBJECT oLbx:aCols[ 6 ]
:bEditValue := { || Desp_Exi(oArticoli) }
END
:CreateFromCode()
END
//Combobox
@ 2, 450 COMBOBOX oLbx:oSortCbx VAR oLbx:cSortOrder;
SIZE 200,400 PIXEL OF oBar HEIGHTGET 18 STYLE CBS_DROPDOWN ;
ON change (oTabs:nOption := oLbx:oSortCbx:nat,;
oTabs:refresh(),;
eval(oTabs:baction),;
Sel_Index(oLbx:oSortCbx:nat,oArticoli,oLbx))
oWinArticoli:oClient := oLbx
oWinArticoli:oControl := oLbx
oTabs:nOption :=1
oWinArticoli:oBottom := oTabs
else
oWinArticoli:SetFocus()
endif
ACTIVATE WINDOW oWinArticoli MAXIMIZED ;
VALID (oWinArticoli:=Nil,.T.)
RETURN NIL
//----------------------------------------------------//
//shows the minimum stock o if it is a lot or Group
Function Desp_Mar(oArticoli)
LOCAL nB:=1
nB:=IF(oArticoli:Minimo<>0 .AND. oArticoli:TotExi<oArticoli:Minimo,2,nB)
nB:=IF(oArticoli:Lote ,4,nB)
nB:=IF(oArticoli:Grupo,5,nB)
nB:=IF(oArticoli:Lote .and. oArticoli:Grupo,6,nB)
nB:=IF(AScan(oT:aSel,oArticoli:CvePro)<>0 ,3,nB)
RETURN (nB)
//----------------------------------------------------//
//shows the current existence
Function Desp_Exi(oArticoli)
LOCAL nTot:=IF(Abs(oArticoli:TotExi)<0.01,0,oArticoli:TotExi)
RETURN (Tran(Abs(nTot),"99,999,999.99"))
//----------------------------------------------------//
Function Desp_Fld1( nInd,oArticoli)
LOCAL cFld
local nBrw:=1 //Control->nBrw=2
* local nBrw:= oControl:nBrw
IF nInd=1
cFld:=oArticoli:CvePro
ELSE
IF nBrw=2
cFld:=oArticoli:Descri+CRLF+oArticoli:DesAdi
ELSE
cFld:=oArticoli:Descri
ENDIF
ENDIF
RETURN (cFld)
//----------------------------------------------------//
Function Desp_Fld2( nInd,oArticoli)
LOCAL cFld
local nBrw:=1 //Control->nBrw=2
* local nBrw:= oControl:nBrw
IF nInd=2
cFld:=oArticoli:CvePro
ELSE
IF nBrw=2
cFld:=oArticoli:Descri+CRLF+oArticoli:DesAdi
ELSE
cFld:=oArticoli:Descri
ENDIF
ENDIF
RETURN (cFld)
//----------------------------------------------------//
Function Sel_Index(nInd,oArticoli,oLbx)
oArticoli:SetOrder(nInd)
IF nInd=1
WITH OBJECT oLbx:aCols[ 2 ]
:cHeader :="Codice"
:nWidth:= 125
END
WITH OBJECT oLbx:aCols[ 3 ]
:cHeader :="Descrizione"
:nWidth:= 365
END
ENDIF
IF nInd=2
WITH OBJECT oLbx:aCols[ 2 ]
:cHeader :="Descrizione"
:nWidth:= 365
END
WITH OBJECT oLbx:aCols[ 3 ]
:cHeader :="Codice"
:nWidth:= 125
END
ENDIF
oLbx:Refresh()
oLbx:SetFocus()
RETURN (Nil)
//--------------------------------------------------------//
Function Orden(oTabs,oArticoli,oLbx,oWinArticoli)
IF oTabs:nOption == 1 //CvePro
oArticoli:SetOrder(1)
ELSEIF oTabs:nOption == 2 //Descri
oArticoli:SetOrder(2)
ENDIF
oLbx:refresh()
oWinArticoli:Update()
RETURN NIL
//--------------------------------------------------------------------------------------------//
CLASS TXData from TDataBase
DATA cDbfPath init cFilePath(GetModuleFileName( GetInstance() )) + "Data\" //for test
DATA cEXEPath init cFilePath(GetModuleFileName( GetInstance() )) //for test
ENDCLASS
CLASS TCatalogo from TXData
METHOD New()
ENDCLASS
METHOD New( lShared ) CLASS TCatalogo
Default lShared := .t.
::super:Open(,::cDbfPath + "Catalogo" ,"DBFCDX", lShared)
if ::use()
::setOrder(1)
::gotop()
endif
RETURN Self
CLASS MA_130
DATA oDat, aEnt, aSal, aSel , nCamD
DATA lIni, lObs, nMov, nSEnt, nSSal
DATA cLin, cMar, cLyM, nFil , nCamE
METHOD New() CONSTRUCTOR
ENDCLASS
METHOD New() CLASS MA_130
::lObs:=.T.
::lIni:=.T.
::nFil:=0
::nMov:=0
::nCamD:=0
::nCamE:=0
::nSEnt:=0
::nSSal:=0
::aSel:={}
::oDat:=Array(23)
::aEnt:=Array(12)
::aSal:=Array(12)
::cLin:="<Tutte>"
::cMar:="<Tutte>"
::cLyM:=""
RETURN (Self)
I tried also to make
- Code: Select all Expand view RUN
@ 0,0 XBROWSE oLbx OF oWinArticoli ;
DATASOURCE oArticoli;
COLUMNS Desp_Fld1(oLbx,oArticoli), "MR", Desp_Fld2(oLbx,oArticoli), ;
Desp_Mar(oArticoli), Desp_Exi(oArticoli) ;
HEADERS cHead1 , "MR", cHead2, "","Existencia" ;
SIZES nS1, 25,nS2, 15, 65 ;
AUTOSORT ;
NOBORDER CELL LINES
....
Function Desp_Fld1( oLbx,oArticoli)
LOCAL cFld
local nInd:= oLbx:oSortCbx:nat
local nBrw:=1 //Control->nBrw=2
* local nBrw:= oControl:nBrw
IF nInd=1
cFld:=oArticoli:CvePro
ELSE
IF nBrw=2
cFld:=oArticoli:Descri+CRLF+oArticoli:DesAdi
ELSE
cFld:=oArticoli:Descri
ENDIF
ENDIF
RETURN (cFld)
//----------------------------------------------------//
Function Desp_Fld2( oLbx,oArticoli)
LOCAL cFld
local nInd:=oLbx:oSortCbx:nat
local nBrw:=1 //Control->nBrw=2
* local nBrw:= oControl:nBrw
IF nInd=2
cFld:=oArticoli:CvePro
ELSE
IF nBrw=2
cFld:=oArticoli:Descri+CRLF+oArticoli:DesAdi
ELSE
cFld:=oArticoli:Descri
ENDIF
ENDIF
RETURN (cFld)
But then make error because it not found oLbx:oSortCbx