Page 1 of 1

CELLNAVIGATION in Grid control (bug)

Posted: Wed Oct 12, 2016 6:02 pm
by KDJ
In grid control definition "CELLNAVIGATION .F." is ignored if "ROWSOURCE" is used.
This property is allways set to .T.:

Code: Select all

#include 'hmg.ch'

FUNCTION Main()

  dbCreate('Users', {{'Name', 'C', 30, 0}, {'Location', 'C', 30, 0}})
  dbUseArea(NIL, NIL, 'Users')
  dbAppend()
  Users->Name     := 'Claudio'
  Users->Location := 'Uruguay'
  dbAppend()
  Users->Name     := 'Krzysztof'
  Users->Location := 'Poland'
  dbGoTop()

  DEFINE WINDOW Main_WA;
    MAIN;
    ROW    100;
    COL    100;
    WIDTH  340;
    HEIGHT 200;
    TITLE  'Grid Test'

    DEFINE GRID Users_GR
      ROW             10
      COL             10
      WIDTH          310
      HEIGHT         100
      HEADERS        {'Name', 'Location'}
      WIDTHS         {150, 150}
      CELLNAVIGATION .F.
      ROWSOURCE      'Users'
      COLUMNFIELDS   {'Name', 'Location'}
    END GRID
  
    DEFINE BUTTON Close_BU
      ROW     130
      COL     120
      WIDTH   80
      HEIGHT  25
      CAPTION 'Close'
      ACTION  Main_WA.RELEASE
    END BUTTON

    ON KEY ESCAPE ACTION Main_WA.RELEASE

  END WINDOW

  //MsgBox(Main_WA.Users_GR.CELLNAVIGATION, 'CELLNAVIGATION') ==> .T.

  IF Main_WA.Users_GR.CELLNAVIGATION
    Main_WA.Users_GR.VALUE := {2, 2}
  ELSE
    Main_WA.Users_GR.VALUE := 2
  ENDIF

  Main_WA.ACTIVATE

RETURN NIL

Re: CELLNAVIGATION in Grid control

Posted: Wed Oct 12, 2016 6:17 pm
by srvet_claudio
I will check.

Re: CELLNAVIGATION in Grid control

Posted: Thu Oct 13, 2016 7:13 pm
by KDJ
Although in the documentation is written:
CellNavigation (D)
...
D: Available at control definition only
we can to force to set CELLNAVIGATION after Grid definition:
Main_WA.Users_GR.CELLNAVIGATION := .F.

In this case, if you try to use RecNo property, run-time error occurs:

Code: Select all

#include 'hmg.ch'

FUNCTION Main()

  dbCreate('Users', {{'Name', 'C', 30, 0}, {'Location', 'C', 30, 0}})
  dbUseArea(NIL, NIL, 'Users')
  dbAppend()
  Users->Name     := 'Claudio'
  Users->Location := 'Uruguay'
  dbAppend()
  Users->Name     := 'Krzysztof'
  Users->Location := 'Poland'
  dbGoTop()

  DEFINE WINDOW Main_WA;
    MAIN;
    ROW    100;
    COL    100;
    WIDTH  340;
    HEIGHT 200;
    TITLE  'Grid Test'

    DEFINE GRID Users_GR
      ROW             10
      COL             10
      WIDTH          310
      HEIGHT         100
      HEADERS        {'Name', 'Location'}
      WIDTHS         {150, 150}
      CELLNAVIGATION .F.
      ROWSOURCE      'Users'
      COLUMNFIELDS   {'Name', 'Location'}
    END GRID
  
    DEFINE BUTTON RecNo_BU
      ROW     130
      COL     120
      WIDTH   80
      HEIGHT  25
      CAPTION '? &RecNo'
      ACTION  MsgBox(Main_WA.Users_GR.RecNo, 'Record')
    END BUTTON

    ON KEY ESCAPE ACTION Main_WA.RELEASE

  END WINDOW

  //MsgBox(Main_WA.Users_GR.CELLNAVIGATION, 'CELLNAVIGATION') ==> .T.

  Main_WA.Users_GR.CELLNAVIGATION := .F.

  IF Main_WA.Users_GR.CELLNAVIGATION
    Main_WA.Users_GR.VALUE := {2, 2}
  ELSE
    Main_WA.Users_GR.VALUE := 2
  ENDIF

  Main_WA.ACTIVATE

RETURN NIL

Re: CELLNAVIGATION in Grid control

Posted: Tue Oct 18, 2016 9:56 pm
by KDJ
srvet_claudio wrote:I will check.
If you checked, I expect some information on this topic.

Re: CELLNAVIGATION in Grid control (bug)

Posted: Sat Oct 22, 2016 8:46 pm
by KDJ
Because "CELLNAVIGATION := .F." with ROWSOURCE does not work properly, for now, I solved the problem in following way:
I used "CELLNAVIGATION := .T." and changed colors of selected row and cell.
CELLNAVIGATION is turned on but it looks like CELLNAVIGATION has been turned off (CELLNAVIGATION without CELLNAVIGATION).

Code: Select all

#include 'hmg.ch'

FUNCTION Main()
  LOCAL aFRowColor
  LOCAL aBRowColor
  LOCAL aFCellColor
  LOCAL aBCellColor

  dbCreate('Users', {{'Name', 'C', 30, 0}, {'Location', 'C', 30, 0}})
  dbUseArea(NIL, NIL, 'Users')
  dbAppend()
  Users->Name     := 'Claudio'
  Users->Location := 'Uruguay'
  dbAppend()
  Users->Name     := 'Krzysztof'
  Users->Location := 'Poland'

  DEFINE WINDOW Main_WA;
    MAIN;
    WIDTH  340;
    HEIGHT 200;
    TITLE  'Grid of Data Test'

    DEFINE GRID Users_GR
      ROW             10
      COL             10
      WIDTH          310
      HEIGHT         100
      HEADERS        {'Record', 'Name', 'Location'}
      WIDTHS         {55, 150, 150}
      //CELLNAVIGATION .F.
      ROWSOURCE      'Users'
      COLUMNFIELDS   {'RecNo()', 'Name', 'Location'}
      JUSTIFY        {GRID_JTFY_RIGHT, GRID_JTFY_LEFT, GRID_JTFY_LEFT}
      ONGOTFOCUS     (CellNavigationColor(_SELECTEDROW_FORECOLOR, aFCellColor), CellNavigationColor(_SELECTEDROW_BACKCOLOR, aBCellColor), CellNavigationColor(_SELECTEDCELL_FORECOLOR, aFCellColor), CellNavigationColor(_SELECTEDCELL_BACKCOLOR, aBCellColor), This.REDRAW)
      ONLOSTFOCUS    (CellNavigationColor(_SELECTEDROW_FORECOLOR, aFRowColor),  CellNavigationColor(_SELECTEDROW_BACKCOLOR, aBRowColor),  CellNavigationColor(_SELECTEDCELL_FORECOLOR, aFRowColor),  CellNavigationColor(_SELECTEDCELL_BACKCOLOR, aBRowColor),  This.REDRAW)
    END GRID
  
    DEFINE BUTTON Record_BU
      ROW     130
      COL     120
      WIDTH   80
      HEIGHT  25
      CAPTION '? &Record'
      ACTION  MsgBox(Main_WA.Users_GR.RECNO, 'Record')
    END BUTTON

    ON KEY ESCAPE ACTION Main_WA.RELEASE

  END WINDOW

  //MsgBox(Main_WA.Users_GR.CELLNAVIGATION, 'CELLNAVIGATION') ==> .T.

  aFRowColor  := CellNavigationColor(_SELECTEDROW_FORECOLOR)
  aBRowColor  := CellNavigationColor(_SELECTEDROW_BACKCOLOR)
  aFCellColor := CellNavigationColor(_SELECTEDCELL_FORECOLOR)
  aBCellColor := CellNavigationColor(_SELECTEDCELL_BACKCOLOR)

  Main_WA.Users_GR.RECNO := 2

  Main_WA.CENTER
  Main_WA.ACTIVATE

RETURN NIL