Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy grid contents

Status
Not open for further replies.

apffal

Technical User
Apr 10, 2004
97
0
0
PT
Is it possible allow the user copy grid contents to a text or editbox ?
If yes, how to do it ?
Thanks !
 
What do you mean "Copy the grid contents"? Whole grid, one cell, one row?

Borislav Borissov
 
What I want is allow the user, by clicking or double clicking one cell or row in the grid, automatically copy its contents to a text or editbox.
Is it possible ?
 
In versions earlier then VFP 8:
In every DblClick EVENT of the .CurrentControl in every column put:

Code:
thisform.Text1.Value = this.Value

In VFP8 or 9
Make a new method in the form named i.e. CopyCell
In Init event (or there where you build the Grid contents) put:

Code:
FOR EACH oColumn IN thisform.Grid1.Columns
    BINDEVENT(oColumn,"DblClick",thisform,"CopyCell",2)
ENDFOR

*** In CopyCell Method
AEVENTS(aEvnt)

thisform.Text1.Value = aEvnt[1].Value

Don't forget to UNBINDEVENTS




Borislav Borissov
 
I'm using FoxPro 6.0 and have a grid with no columns.
So, is it enough put that code (thisform.Text1.Value = this.Value)in grid´s DblClick EVENT ?

 

Appfal,

No, not the grid's DblClick. If you did that, the event would only fire when the user clicks an empty part of the grid.

You need to put it in the DblClick of the actual controls (textboxes or whatever) in both the columns.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
When you use VFP 6 I think there is no way to catch the DblClick event when you build the Grid Dynamacaly other way that put ion each Grid Column your own control.
Something like this:
In some PRG you have a SET PROCEDURE TO it:
Code:
DEFINE CLASS MyTextBox AS TextBox
   PROCEDURE DblClick
       IF PEMSTATUS(thisform,"ClickEvent", 5)
          thisform.ClickEvent()
       ENDIF
   ENDPROC
ENDDEFINE

There where you build the grid:

Code:
thisform.Grid1.recordSource = "YourTable"
FOR EACH oColumn IN thisform.Grid1.Columns
    IF TYPE("oColumn.MyText1") # "O"
       oColumn.AddObject("MyText1", "MyTextBox")
       oColumn.CurrentControl = "MyText1"
       oColumn.MyText1.Visible = .t. && This is important
    ENDIF
ENDFOR





Borislav Borissov
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top