- Code: Select all Expand view
#include "FiveWin.ch"
#include "xbrowse.ch"
PROC MAIN()
********************
LOCAL oDlg
LOCAL WinTit := "Test BrwFitSize"
LOCAL oBrw1 , oBrw2 , aData1 , aData2 , aData
aData1 := {"el 1","el 2", "el 3"}
aData2 := {{"el 1",{"el 11","el 12" , "el 13" , "el 14","el 15" , "el 16"}},;
{"el 2",{"el 21","el 22" , "el 23"}},;
{"el 3",{"el 31","el 32" , "el 33" , "el 34","el 35" , "el 36"}}}
aData := aData2[1,2]
DEFINE DIALOG oDlg SIZE 900,600 PIXEL TITLE WinTit
@ 2 ,2 XBROWSE oBrw1 OF oDlg ARRAY aData1;
SIZE 50 , 230 PIXEL;
AUTOCOLS LINES
WITH OBJECT oBrw1
:lRecordSelector := .F.
:lHscroll := .F.
:bChange := {|self,lRow|oBrw2:aArrayData := aData2[oBrw1:nArrayAt,2] ,;
oBrw2:BrwFitSize(.T.) , oBrw2:Refresh(.T.)}
:CreateFromCode()
END
@ 2, 100 XBROWSE oBrw2 OF oDlg ARRAY aData;
SIZE 50 , 230 PIXEL;
AUTOCOLS LINES
WITH OBJECT oBrw2
:lRecordSelector := .F.
:lHscroll := .F.
:CreateFromCode()
END
ACTIVATE DIALOG oDlg CENTER ON INIT oBrw2:BrwFitSize(.T.)
RETURN
Starting this aplication , RowCount() from oBrw2 is adjusted to 6 elements , the second browse fit's to 6 elements.
Giving el2 from obrw1 (second row) focus adjust rowcount() from obrw2 to 3 elements , the second browse fit's to 3 elements , CORRECT !
Giving el3 from obrw1 (third row) focus adjust rowcount() from obrw2 to 3 elements , the second browse fit's to 3 elements , FALSE , it should be 6 !
Originally oBrw2 could have 24 elements. BrwFitsize overwrite oBrw2:nHeight , the originally value is lost
I added a second parameter to BrwFitSize (nMaxRow) , BrwFitSize should be replaced with BrwFitSize(.T.,nMaxRow)
- Code: Select all Expand view
LOCAL nMaxRow
......
:bChange := {|self,lRow|oBrw2:aArrayData := aData2[oBrw1:nArrayAt,2] ,;
oBrw2:BrwFitSize(.T. , nMaxRow) , oBrw2:Refresh(.T.)}
......
ACTIVATE DIALOG oDlg CENTER ON INIT (nMaxRow := oBrw2:RowCount() , oBrw2:BrwFitSize(.T. , nMaxRow))
METHOD BrwFitSize( lReSize , nMaxRow ) CLASS TXBrowse
...
DEFAULT nMaxRow := ::RowCount()
...
nHeight := Max( 3, Min( nMaxRow, ::KeyCount() ) ) * ::nRowHeight + ;
If( ::lHeader, ::nHeaderHeight, 0 ) + ;
If( ::lFooter, ::nFooterHeight, 0 ) + 1 + nY
Frank