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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to display a memo field in a grid ?

Status
Not open for further replies.

pxw

Programmer
Jan 6, 2002
86
AU
Following is the codes I want to display a memory field in a grid. It doesn't work.

select service
thisform.gridserv.column2.width =400
thisform.gridserv.column2.HEADER1.CAPTION="Service comment"
thisform.gridserv.column2.controlSource ="service.comment" &&comment is a memo field of service.dbf

Any help would be appreciated.


Peter
 
pxw

try

thisform.gridserv.column2.Text1.controlSource ="service.comment"
HTH

Chris [pc2]
 
You could use an EditBox as a currentcontrol of your column where your memo is. And put your column setting to sparse = .f.
Like this, in the init of the grid:
Code:
this.ColumnCount = 4
this.column4.AddObject('myEdit','editbox')
this.column4.myedit.visible = .t.
this.column4.currentcontrol='myEdit'
this.column4.sparse = .f.
this.RowHeight = 30


 
Hi All,
Thanks a lot for your quick responses.

ChrisRChamberlain, Trying your codes, I got the error message, "parent object will allow this property setting for thisform.gridserv.column2.Text1.controlSource ="service.comment". Am I doing something wrong?

mgagnon, your codes work very well! Furthermore, do you have any idea how to set wordwrap in the editbox? Gerenally, the lengh of a memo field is long.


Peter
 
I believe that wordwrap is automatic in an editbox. What's variable is (vertical) scroll bars. Actually, in at least VFP 7 you can't have horizontal scroll bars. But you can use the arrow keys and pageup / pagedown if you don't want the vertical scroll bars. Dave Dardinger
 
pxw

What I didn't notice was that you had not included a .RecordSource for your grid.

select service
thisform.gridserv.RecordSource = "service"
thisform.gridserv.column2.width =400
thisform.gridserv.column2.HEADER1.CAPTION="Service comment"
thisform.gridserv.column2.controlSource ="service.comment"

If .AllowRowSizing = .T., .RecordMark = .T. and .Columnn.Resizable = .T., the user can resize the grid to suit if you want to use an editbox.

By default, double clicking a memo field in a grid will bring up an edit window.

You could get this window to appear with a single click if you put:-

MODI MEMO SERVICE.comment [NOEDIT]

in the .Click() event of the textbox.

The [NOEDIT] will make the memo field's contents read-only if applicable.

An edit window can be resized to full screen if required and is not constrained by the dimensions of the grid.

Assuming you are using a FOXUSER.dbf, the coordinates will be automatically saved.

There is no print facility for an editbox, so printing the contents of a memo field will become a pain.

There are no formatting facilities for an editbox, nor can you set the properties of an editbox to show row numbers, wordwrap, drag and drop editing, etc.


If you want to get the best of both worlds, put:-

MODI MEMO SERVICE.comment [NOEDIT]

in the .DblClick() event of the editbox, or substitute a commandbutton for the editbox and use the single click code. HTH

Chris [pc2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top