Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to validate movement from row to row in a grid?
Message
From
06/07/1999 10:37:14
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00237681
Message ID:
00237745
Views:
8
>How to validate movement from row to row in a grid?
>In BROWSE we have WHEN clause, but in a grid...
>
>May be decision is in usage of BeforeRowColChange and AfterRowColChange events, but it seems that in this events we don't know if movement is from row to row or from column to column.
>
>I decided this problem partially with new property and some checking.
>
>Please help.
>Nik
Hi Nik,
Couldn't strip all from class code but you'll see the basics. Original class code is also supported with grid.valid event code. Otherwise user just might attempt to click outside of grid and defeat the check.
PROCEDURE BeforeRowColChange
LPARAMETERS nColIndex
llChangingRow = .f.
WITH this
  oColumn = .columns(.FindColumn(nColIndex))
  IF lastkey() = 145 && Ctrl+Dn, Adding new rec - self choice
    .nLastValidRec = .nCurrec
  ENDIF
  thisform.LockScreen = .lInGrid
  IF mdown()
    lnBottom		= .top+.headerheight+.relativerow * .rowheight
    lnTop		= lnBottom - this.rowheight
    lnMouseRowPos	= mrow(wontop(),3)
    lnMouseColPos	= mcol(wontop(),3)
    llChangingRow	= !(between(lnMouseRowPos,lnTop, lnBottom) ;
      and between(lnMouseColPos,.left,.left+.width))
  ELSE
    llChangingRow	= inlist(lastkey(),24,5,18,3,145,148)
  ENDIF

  IF llChangingRow
    IF !empty(oColumn.dynamiccurrentcontrol)
      cCurrentControl = eval(oColumn.dynamiccurrentcontrol)
    ELSE
      cCurrentControl = oColumn.currentcontrol
    ENDIF
    WITH evaluate("oColumn."+cCurrentControl)
      .value = .value && So we can evaluate table ruleexpression
    ENDWITH
    oColumn = .null.
    IF !empty(dbgetprop(.recordsource,"Table","RuleExpression")) ;
        and !evaluate(dbgetprop(.recordsource,"Table","RuleExpression"))
      thisform.LockScreen = .F.
      IF messagebox(.cRevertMessage,4+16,"") = 6
        TABLEREVERT(.f.,.recordsource)
        .recchange()
      ELSE
        NODEFAULT
      ENDIF
    ENDIF
  ENDIF
ENDWITH
ENDPROC

PROCEDURE FindColumn
LPARAMETERS nColIndex
LOCAL ix
WITH this
  FOR ix = 1 to .columncount
    IF .columns(ix).ColumnOrder = nColIndex
      RETURN ix
    ENDIF
  ENDFOR
ENDWITH
ENDPROC
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform