Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Right click in grid.
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00064099
Message ID:
00064106
Vues:
24
>Hi,
>
>I've read the threads I could find on this, but can't get mine to work. What I'm attempting to do is allow the user to rightclick on a row/column in a grid (there could be many columns and rows) of data and have a popup shortcut menu be displayed (I have code for that) that would enable the user to select Delete, New or whatever and it would then delete the record that was selected in the grid.
>
>Any way of implementing this? I found a RightClick event in the Header and the Grid, but not in the column.
>
>Thanks,

Hi Jim
Don't know how I'll go on this answer but here we go.
Basically, first you need some programatic class definitions for your columns with code in their .RightClick method to call your s/cut menu either directly or calling the form's RightClick which would contain the call to the menu, depending on the behav. you want.
We have a baseclass grid for grids that want a rclick. In its init is the following code. The col definitions are below.

*-RCGRID Init Code
IF !DODEFAULT()
RETURN .F.
ENDIF
IF !EMPTY(this.RecordSource)
=AFIELDS(laFlds,this.RecordSource)
This.ColumnCount = 0
lnx = 0
lxx = ALEN(laFlds)/16
FOR lx = 1 TO lxx
lnx = lnx + 1
lcColumn = "Column"+AllTrim(Str(lnx))
This.AddObject(lcColumn,"RcColumn")
WITH this.Columns[THIS.ColumnCount]
.ControlSource = This.RecordSource+"."+ALLT(laFlds(lnx,1))
.Visible = .T.
.Header1.Caption = PROPER(ALLT(laFlds(lnx,1)))
EndWith
NEXT
ENDIF

*- RightClick grid cols class defs
DEFINE CLASS RcColumn AS COLUMN
ADD OBJECT Header1 AS RcHeader
ADD OBJECT Text1 AS RCTextBox
ENDDEFINE
DEFINE CLASS RCHeader AS HEADER
PROCEDURE RIGHTCLICK
ThisForm.RightClick()
ENDPROC
ENDDEFINE
* note sele on entry in testbox
* might want to make this a user modi form prop
DEFINE CLASS RCTextBox AS TEXTBOX
BorderStyle = 0
SelectOnEntry = .T.
PROCEDURE RIGHTCLICK
ThisForm.RightClick()
ENDPROC
ENDDEFINE

So what happens then is.
Throw the rcGrid on the form.
As the form runs it's init it adds a col for each field in the table and these cols have the rclick behav. you want

The line
This.ColumnCount = 0
is important
and so is the
.Visible = .T. as each col is added.

See how that goes
John
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform