FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour xBrowse as Excel behaviour
Posts: 417
Joined: Tue Feb 23, 2010 03:09 PM
xBrowse as Excel behaviour
Posted: Fri Jan 14, 2011 09:23 AM

Mr. Rao,

How can xBrowse works as Excel behaviour, for example, when you press Enter a new line is created, etc?.

Thank you

FWH 11.11, Harbour 3.1 and Borland C++ 5.82
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: xBrowse as Excel behaviour
Posted: Fri Jan 14, 2011 05:49 PM

UKService,

This code works with TWBrowse, but I haven't tried it with TXBrowse:

oLbx:bKeydown := {|nKey,nFlags| ;
IIF(nKey == VK_RETURN, ::edit(),)}

You would have to add a record to the DBF, then refresh the browse. Replace ::edit() with your own function.

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse as Excel behaviour
Posted: Sat Jan 15, 2011 03:05 AM
By default, XBrowse mostly behaves like Excel when columns are Editable and FastEdit is enabled.

Pressing any key enters edit mode with that key as the first key and if edit is exited with up or down arrow the cursor moves to the cell above or below the current cell like Excel.

If only some columns are editable, the behavior is identical to Excel where some cells are protected. Cursor jumps to the next editable cell in both cases. Editable cell is the cell where oCol:nEditType > 0 and oCol:bEvalWhen is nil or evaluates to .t..

One difference betwen Excel and Xbrowse is that in Excel, pressing Enter key does not invoke edit but moves the cursor to the next column, whereas in XBrowse, by default, Enter key enters edit. F2 key invokes edit in Excel, where as this key is ignored in XBrowse.

Even in this case, XBrowse can be set to mimic fully Excel behavior by setting
Code (fw): Select all Collapse
oBrw:lEnterKey2Edit := .f.  // ( default .t. )
oBrw:lF2KeyToEdit   := .t.  // ( default .f. )

With these settings, XBrowse behaves fully like Excel.

There is another feature in Excel. We can enter "=400*20" to get 8000. By default this is not possible with XBrowse.
But by setting
Code (fw): Select all Collapse
oBrw:lFormulaEdit := .t. // (default .f. )

we can enter formulae in XBrowse cells too, like we do in Excel. One difference between Excel and XBrowse is that Excel remembers the fomula forever but XBrowse evaluates the expression and stores the result, discarding the formula. Still this feature is very useful to the users who can enter simple calculations directly into the cells, instead of using calculator before entering into the cells.

For automatically creating new rows, oBrw:bPastEof may be assigned with appropriate codeblock to instruct xbrowse what to do when the user is navigating past the eof. There are some samples in the samples folder explaining the usage.

XBrowse is feature rich, but many of the features are not available to those who still use the very old way of programming like using oCol:bStrData.... ,etc.
Regards



G. N. Rao.

Hyderabad, India

Continue the discussion