xBrowse a recordset from a WinChild

xBrowse a recordset from a WinChild

Postby Rick Lipkin » Thu May 21, 2009 6: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: Select all  Expand view

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 )
 
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: xBrowse a recordset from a WinChild

Postby nageswaragunupudi » Thu May 21, 2009 8:00 pm

Please try this code
Code: Select all  Expand view

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
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 108 guests