A Question about (FiveLinux) Class TWBrowse

A Question about (FiveLinux) Class TWBrowse

Postby xProgrammer » Fri Sep 05, 2008 8:32 am

Hi Antonio

I don't quite know how to do something. Take a TWBrowse. I want to be able to set the default selection to some position other than 1. I can do this by setting oBrw:nAt but the issue is if I set that to record n then records 1 through n-1 aren't displayed. Is there a way around this? To date I have been skirting the issue by re-ordering the arrays that are browsed so the record I want selected as default is in position 1, but I am coming to situations where this is less than desirable. Can you advise?

You can see the issue using the testbrwa.prg program you sent me with the addition of 1 line as follows:

Code: Select all  Expand view
// Using a browse to display a multidimensional array

#include "FiveLinux.ch"

function Main()

   local oWnd, oBrw, aTest := { { "one", "two" }, { "three", "four" } }

   DEFINE WINDOW oWnd TITLE "Testing Browses" SIZE 522, 317

   @ 2, 2 BROWSE oBrw OF oWnd ;
      HEADERS "First", "Second" ;
      FIELDS  aTest[ oBrw:nAt ][ 1 ], aTest[ oBrw:nAt ][ 2 ]

   oBrw:SetArray( aTest )
   oBrw:nAt := 2              // this is the line I added to set record 2 as the "default" choice.

   @ 28, 2 BUTTON "_Ok" OF oWnd ACTION oWnd:End()
   
   @ 28, 30 BUTTON "Add" OF oWnd ACTION ( AAdd( aTest, { "five", "six" } ), oBrw:SetArray( aTest ), oBrw:GoTop() )

   ACTIVATE WINDOW oWnd

return nil


I note that in TDialog there is an intriguing piece of code to do with TListbox objects, namely:

Code: Select all  Expand view
   // Listbox controls initialization workaround
   for n = 1 to Len( ::aControls )
      if ::aControls[ n ]:ClassName() == "TLISTBOX"
         ::aControls[ n ]:SelItem( ::aControls[ n ]:nAt )
      endif
   next


Is this to overcome a comparable issue with list boxes? Is there a way of having an equivalent to SelItem() in TWBrowse?

Regards
Doug
(xProgrammer)
User avatar
xProgrammer
 
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Postby Antonio Linares » Mon Sep 08, 2008 11:23 am

Doug,

Please try this workaround:

oBrw:SetArray( aTest )
oBrw:GoDown()

or for n rows:
Code: Select all  Expand view
for n = 1 to nRows
   oBrw:GoDown()
next
regards, saludos

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

Postby xProgrammer » Mon Sep 08, 2008 11:57 am

Hi Antonio

I think I had already tried this "trick" but it doesn't work because the n-th row is put at the top of the browse and the rows above aren't visible. (Unless you arrow up to them which is no good and moves the default selection you have just set.)

Here is the example:

Code: Select all  Expand view
// Using a browse to display a multidimensional array

#include "FiveLinux.ch"

function Main()

   local oWnd, oBrw, aTest := { { "one", "two" }, { "three", "four" } }

   DEFINE WINDOW oWnd TITLE "Testing Browses" SIZE 522, 317

   @ 2, 2 BROWSE oBrw OF oWnd ;
      HEADERS "First", "Second" ;
      FIELDS  aTest[ oBrw:nAt ][ 1 ], aTest[ oBrw:nAt ][ 2 ]

   oBrw:SetArray( aTest )
   //oBrw:nAt := 2
   oBrw:GoDown()

   @ 28, 2 BUTTON "_Ok" OF oWnd ACTION oWnd:End()
   
   @ 28, 30 BUTTON "Add" OF oWnd ACTION ( AAdd( aTest, { "five", "six" } ), oBrw:SetArray( aTest ), oBrw:GoTop() )

   ACTIVATE WINDOW oWnd

return nil


Regards
Doug
User avatar
xProgrammer
 
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Postby Antonio Linares » Mon Sep 08, 2008 2:01 pm

Doug,

This is not working totally right yet, but we are closer :-)

oBrw:SetArray( aTest )
oBrw:nRowPos = 2
regards, saludos

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

Postby Antonio Linares » Mon Sep 08, 2008 2:16 pm

No, it is not a right solution as oBrw:nAt is not properly set :-(
regards, saludos

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

Postby Antonio Linares » Mon Sep 08, 2008 2:33 pm

This is better:

oBrw:SetArray( aTest )
oBrw:nAt = 2
oBrw:nRowPos = 2
regards, saludos

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


Return to FiveLinux / FiveDroid (Android)

Who is online

Users browsing this forum: No registered users and 8 guests

cron