FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Assigning columns to listbox programmatically
Posts: 233
Joined: Sat Dec 30, 2006 06:10 AM
Assigning columns to listbox programmatically
Posted: Tue May 29, 2007 06:57 PM
Is there anything wrong with the way I have created the columns at runtime?

And how do I remove these columns and replace them with others? I want to change the columns in the listbox when the user changes the database order for example.

     DEFINE COLUMN BROWSE oListBox ID 40 OF oDlg_Search UPDATE ON DblClick ( lResult := .T., oDlg_Search:End() )
         oListBox:cALIAS = cALIAS
         aFlds := {"COMPANY","SURNAME","FIRSTNAME","TEL1"}
         aTitles := {"Company","Surname","FIRSTNAME","Telephone"}
         aWidths := {90,100,90,100}

      FOR i := 1 TO LEN( aFlds )
         cTemp := aFlds[ i ]
         ADD TO BROWSE oListBox DATA &cTemp HEADER aTitles[ i ] OEM ALIGN LEFT WIDTH aWidths[ i ] PIXELS
      NEXT
Many thanks

Ollie.



Using:

xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)

Borland C++ 5.5.1

FWH 9.04 (2009 Apr)
Posts: 1074
Joined: Fri Oct 07, 2005 01:56 PM
Assigning columns to listbox programmatically
Posted: Tue May 29, 2007 09:22 PM
Prueba con esto?

FOR i := 1 TO LEN( aFlds )
      MakeBrow( aFld, oListBox, aTitle, aWidths, i )
NEXT i

//BLABLA

function MakeBrow( aFld, oLisBox, aTitle, aWidths, i )
local cTemp := aFlds[ i ]

        ADD TO BROWSE oListBox DATA &cTemp HEADER aTitles[ i ] OEM ALIGN LEFT WIDTH aWidths[ i ] PIXELS

return  nil
Saludos
Patricio

__________________________________________________________________
Version: Harbour 3.2.0dev (r1307082134),Compiler: Borland C++ 5.8.2 (32-bit)
PCode version: 0.3, FWH 13.2
http://www.sialm.cl
Posts: 233
Joined: Sat Dec 30, 2006 06:10 AM
Assigning columns to listbox programmatically
Posted: Wed May 30, 2007 06:16 AM

Hi, maybe I was misunderstood. The code DOES WORK, I am just not sure if it is 'good' programming practice to use a &macro like this. If its ok, I will leave it as it is because it works.

What I still do need to know is how to change the columns that are displayed. E.g. When the user changes the Database order from SURNAME to COMPANY, I want the columns shown to be different.

Many thanks

Ollie.



Using:

xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)

Borland C++ 5.5.1

FWH 9.04 (2009 Apr)
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Assigning columns to listbox programmatically
Posted: Wed May 30, 2007 06:56 AM

Ollie,

> I want the columns shown to be different

You just need to refresh the browse oBrowse:Refresh()

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 233
Joined: Sat Dec 30, 2006 06:10 AM
Assigning columns to listbox programmatically
Posted: Wed May 30, 2007 07:10 AM

Ok, I get that, but how do I REMOVE the columns I don't want, so I can add new columns?

Many thanks

Ollie.



Using:

xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)

Borland C++ 5.5.1

FWH 9.04 (2009 Apr)
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Assigning columns to listbox programmatically
Posted: Wed May 30, 2007 08:26 AM

Ollie,

oBrowse:aColumns := {}

... add columns

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion