FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour xBrowse a recordset from a WinChild
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
xBrowse a recordset from a WinChild
Posted: Thu May 21, 2009 06:04 PM
To All

I must be doing something very wrong here. I am taking my 'listbox' code for an ADO recordset and modifying it for xBrowse.

The program compiles .. but when the browse fires ... all I get is a Grey mdichild window .. no data .. just blank.

Here is the code :
Code (fw): Select all Collapse
oRs:MoveFirst()

DEFINE WINDOW oGRP                         ;
      FROM 2,2 to 25,80                    ;
      of oWndMDI                           ;
      TITLE "HOLIDAY Schedule"             ;
      MENU BuildMenu( oRs )                ;
      NOMINIMIZE                           ;
      NOZOOM                               ;
      MDICHILD

@ 0, 0 xBrowse oBrow of oGrp RECORDSET oRs  ;
       FIELDS ;
       dtoc(oRs:Fields("begin_date"):Value),;
       dtoc(oRs:Fields("end_date"):Value),  ;
       oRs:Fields("holiday"):Value          ;
       SIZES 90,90,200                      ;
       HEADERS "Begin DT",                  ;
               "End DT",                    ;
               "Holiday"                    ;
       AUTOSORT FASTEDIT LINES CELL

   oBrow:bClrRowFocus    := { || { CLR_BLACK, RGB(185,220,255) } }
   oBrow:nMarqueeStyle   := MARQSTYLE_HIGHLROWMS


//  ;
   *    ON DBLCLICK( _HoliView( "V", oRs ))  ;
   *    UPDATE


      oBrow:bLogicLen := { || oRs:RecordCount }
      oBrow:bGoTop    := { || oRs:MoveFirst() }
      oBrow:bGoBottom := { || oRs:MoveLast() }
      oBrow:bSkip     := { | nSkip | Skipper( oRs, nSkip ) }
      oBrow:cAlias    := "ARRAY"


      oGrp:oClient := oBROW
      oGrp:SetControl( oBrow )


ACTIVATE WINDOW oGRP           ;
      VALID ( IIF( !lOK, GrpCLose( .T. , oRs ), .F. ))

RETURN( NIL )

//-------------------------------
STATIC FUNCTION SKIPPER( oRsx, nSkip )

LOCAL nRec := oRsx:AbsolutePosition

oRsx:Move( nSkip )

IF oRsx:EOF; oRsx:MoveLast(); ENDIF
IF oRsx:BOF; oRsx:MoveFirst(); ENDIF

RETURN( oRsx:AbsolutePosition - nRec )
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse a recordset from a WinChild
Posted: Thu May 21, 2009 08:00 PM
Please try this code
Code (fw): Select all Collapse
oRs:MoveFirst()

DEFINE WINDOW oGRP                         ;
      FROM 2,2 to 25,80                    ;
      of oWndMDI                           ;
      TITLE "HOLIDAY Schedule"             ;
      MENU BuildMenu( oRs )                ;
      NOMINIMIZE                           ;
      NOZOOM                               ;
      MDICHILD

@ 0, 0 XBrowse oBrow of oGrp ;
       RECORDSET oRs ;
       COLUMNS 'begin_date', 'end_date', 'holiday' ;
       HEADERS 'Begin DT', 'End DT', 'Holiday' ;
       COLSIZES 90, 90, 200 ;  // sizes is not normally necessary. XBrowse allots appropriate space to each column
       AUTOSORT FASTEDIT LINES

   // The following 2 lines are not compatible with Editing. For display and selection, its ok
   oBrow:bClrRowFocus    := { || { CLR_BLACK, RGB(185,220,255) } }  
   oBrow:nMarqueeStyle   := MARQSTYLE_HIGHLROWMS

   // for the columns you want to edit.
   // example
   oBrow:aCols[ 1 ]:nEditType := EDIT_GET

   oBrow:CreateFromCode()
   oGrp:oClient          := oBrow
   
   ACTIVATE WINDOW oGRP   // VALID ( IIF( !lOK, GrpCLose( .T. , oRs ), .F. ))

RETURN( NIL )


With XBrowse DToC( .. ) is not necessary XBrowse knows the datatypes and their sizes and formats appropriately. XBrowse also provides necessary codeblocks like bGoTop, bSkip etc by itself. It is just enough for us to say what columns to be shown and whether we want to edit or not. Xbrowse knows how to read and write to recordset.
Regards



G. N. Rao.

Hyderabad, India

Continue the discussion