CELLNAVIGATION in Grid control (bug)

Moderator: Rathinagiri

Post Reply
KDJ
Posts: 178
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland
Been thanked: 183 times

CELLNAVIGATION in Grid control (bug)

Post by KDJ » Wed Oct 12, 2016 6:02 pm

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
Last edited by KDJ on Thu Oct 13, 2016 7:15 pm, edited 1 time in total.

User avatar
srvet_claudio
Posts: 1952
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 31 times
Been thanked: 119 times
Contact:

Post by srvet_claudio » Wed Oct 12, 2016 6:17 pm

I will check.
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com

KDJ
Posts: 178
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland
Been thanked: 183 times

Post by KDJ » Thu Oct 13, 2016 7:13 pm

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

KDJ
Posts: 178
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland
Been thanked: 183 times

Post by KDJ » Tue Oct 18, 2016 9:56 pm

srvet_claudio wrote:I will check.
If you checked, I expect some information on this topic.

KDJ
Posts: 178
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland
Been thanked: 183 times

Post by KDJ » Sat Oct 22, 2016 8:46 pm

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

Post Reply