Assigning columns to listbox programmatically

Assigning columns to listbox programmatically

Postby Ollie » Tue May 29, 2007 6: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.

Code: Select all  Expand view
     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)
Ollie
 
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am

Postby Patricio Avalos Aguirre » Tue May 29, 2007 9:22 pm

Prueba con esto?

Code: Select all  Expand view
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
User avatar
Patricio Avalos Aguirre
 
Posts: 1060
Joined: Fri Oct 07, 2005 1:56 pm
Location: La Serena, Chile

Postby Ollie » Wed May 30, 2007 6: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)
Ollie
 
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am

Postby Antonio Linares » Wed May 30, 2007 6: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42078
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Ollie » Wed May 30, 2007 7: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)
Ollie
 
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am

Postby Antonio Linares » Wed May 30, 2007 8:26 am

Ollie,

oBrowse:aColumns := {}

... add columns
regards, saludos

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


Return to FiveWin for Harbour/xHarbour

Who is online

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