Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Double-Click in a Grid
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00083233
Message ID:
00083301
Vues:
21
>I've used the double click event in the active control in the grid column. As far as I can tell I have to set the method code in each columns' active controls' click event.

One way to generalize a solution for this is to subclass a textbox as follows:
Define class grdTextBox as TextBox
  cDblClick=""
Function Init
  Lparam cDblClickRoutine
  This.cDblClick=cDblClickRoutine
  EndFunc
Function DblClick
  If Empty(This.cDblClick)
    Return
  Endif
  Do (This.cDblClick)
  EndFunc
EndDefine
This can be done with the visual class designer as well. If you are dynamically instantiating the grid, you can use a syntax like:
with oColumn
  .RemoveObject("Text1")   && Remove default
  .Addobject("Text1","grdTextBox", "MyDblCLickRoutineName")
Endwith
When the user double clicks the textbox, your routine called MyDblCLickRoutineName will be called. Note that MyDblCLickRoutineName must be either a .PRG file or in a file denoted via SET PROCEDURE TO. You can pass parameters in the line of code that says Do (This.cDblClick) if you want to.

Using this technique, you sacrifice some encapsulation to gain some flexibility. You can use the same class (without having to subclass further) to invoke different DblClick routines by specifying the name of your "external" DblClick routine in your AddObject call. You can do likewise with Click and Rightclick events if you want.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform