Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Move rows in a grid with combobox program?
Message
De
09/12/2008 11:51:23
 
 
À
09/12/2008 09:47:45
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01366188
Message ID:
01366222
Vues:
15
Now with the combobox in Col 1, focus seems to get set to that first and then the down arrow gets used by the combobox to move choices in it.
**************************************************
*-- Class:        cbogrddropdown 
*-- ParentClass:  combobox
*-- BaseClass:    combobox
*-- Drop Down List for use in a grid. special navigation key handling
*
Define Class cbogrddropdown As ComboBox


  Height = 21
  SpecialEffect = 1
  Style = 2
  Width = 75
  BorderStyle = 0
  *-- Save original setting of _DBLCLICK...facilitate incremental searching
  nolddblclick = 0
  Name = "cbogrddropdown"

  *-- Set to true when the list is dropped so we know how to handle the cursor keys
  ldroppeddown = .F.

  *-- Save the original value of the combo when it gets focus
  uoldval = .F.

  *-- an array property to hold the rowsource when this is using a rowsourcetype f 5-array
  Dimension acontents[1]


  *-- Handle the cursor keys differently depending on whether or not the combo is dropped down
  Procedure handlekey
    Lparameters nKeyCode
    Local lnMaxRow, llRetVal

    With This
      *** If escape or enter pressed, the list is not dropped down anymore
      If nKeyCode = 27 Or nKeyCode = 13
        .ldroppeddown = .F.
      Endif
      *** If the list is not dropped down, traverse the grid with cursor keys
      If !.ldroppeddown
        With .Parent.Parent
          *** Calculate the maximum number of rows in the grid
          lnMaxRows = Int( ( .Height - .HeaderHeight - ;
            IIF( Inlist( .ScrollBars, 1, 3 ),;
            SYSMETRIC( 8 ), 0 ) ) / .RowHeight )
          *** Move up a row in the grid: up arrow key pressed
          If nKeyCode = 5 Then
            *** If we are sitting on the top row in the visible portion of the grid,
            *** Scroll the grid up a row in case there is a previous record
            If .RelativeRow = 1
              .DoScroll( 0 )
            Endif
            .ActivateCell( .RelativeRow - 1, .ActiveColumn )
            *** Let KeyPress know we have handled the keystroke
            llRetVal = .T.
          Else
            *** Move down a row in the grid if the down arrow key is pressed and the
            *** combo box is closed
            *** If we are sitting on the bottom row in the visible portion of the grid,
            *** Scroll the grid down a row in case there is a next record
            If nKeyCode = 24 Then
              If .RelativeRow >= lnMaxRows
                .DoScroll( 1 )
              Endif
              .ActivateCell( .RelativeRow + 1, .ActiveColumn )
              llRetVal = .T.
            Endif
          Endif
        Endwith
      Endif
    Endwith

    Return llRetVal
  Endproc


  Procedure LostFocus
    *** We now need code to check the version number here because VFP 7
    *** Does not use _DBLCLICK for Incremental Search
    If Version( 5 ) > 699
      _Incseek = This.nolddblclick
    Else
      _Dblclick = This.nolddblclick
    Endif
  Endproc


  Procedure KeyPress
    Lparameters nKeyCode, nShiftAltCtrl
    If This.handlekey( nKeyCode )
      Nodefault
    Endif
  Endproc


  Procedure DropDown
    This.ldroppeddown = .T.
  Endproc


  Procedure Click
    This.ldroppeddown = .F.
  Endproc


  Procedure GotFocus
    With This
      *** Save Original value in case we have to restore it later
      .uoldval = .Value
      *** Facilitate incremental searching in the drop down
      If Version( 5 ) > 699
        *** We are in VFP 7.0 or later
        .nolddblclick = _Incseek
        _Incseek = 1.5
      Else
        .nolddblclick = _Dblclick
        _Dblclick = 1.5
      Endif
    Endwith
  Endproc


  Procedure Init
    If DoDefault()
      This.Setup()
    Endif
  Endproc


  *-- Called from the init() to do any setup work in the combo
  Procedure Setup
  Endproc


Enddefine
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform