Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Vilhelm-Ion Praisach
  Where is Vilhelm-Ion Praisach?
 Resita
 Romania
 Vilhelm-Ion Praisach
 To: chaim dudi
  Where is chaim dudi?
 Jerusalem
 South Carolina - Israel
 chaim dudi
 Tags
Subject: RE: Grid text wrapping
Thread ID: 416367 Message ID: 416378 # Views: 63 # Ratings: 4
Version: Visual FoxPro 9 SP2 Category: Grids
Date: Sunday, December 28, 2014 7:41:53 PM         
   


> Hi experts,
>
> Help please
>
> I have a grid with few columns permanent width.
> The content length of all columns is also permanent except one column.
>
> Is it possoble to tell vfp that if len of this column>10, show something similar to one of the three examples below (row 3):
>
> Thank you

The second version can be achieved with VFP grid.

PUBLIC oFrm
ofrm = CREATEOBJECT("myform")
ofrm.show()

FUNCTION getlines
	LPARAMETERS lnId,lcText,lnWidth
	LOCAL lcWidth,lcFinalText
	lcFinalText=""
	lcWidth = SET("Memowidth")
	Set Memowidth To m.lnWidth
	lcFinalText = Mline(m.lcText,1)
	For lnCount = 2 to Memlines(m.lcText)
		INSERT INTO dd (ID,Message,nRow) VALUES (m.lnId,Mline(m.lcText,m.lnCount),m.lnCount)
	Endfor 
RETURN m.lcFinalText

DEFINE CLASS MyForm as Form
	nColumnWidth = 16 && number of chars
	width = 500
	ADD OBJECT grd as grid ;
		WITH width = 450,;
		columncount = 5,;
		RecordSourceType = 4,;
		RecordSource = 'Select * FROM dd order by ID,nRow INTO CURSOR ee'
	PROCEDURE Load
		LOCAL lcFinalText,lnRec
		CREATE CURSOR cc (ID I,Received D,Message C(100),Priority I,Done C(1))
		INSERT INTO cc VALUES (1,DATE(2014,12,11),'ABC BBB ARC ABC',6,'Y')
		INSERT INTO cc VALUES (2,DATE(2014,12,12),'ABC',9,'Y')
		INSERT INTO cc VALUES (3,DATE(2014,12,12),'ABC EBC ATC ABC AQQ AET AEG AER HRS GTT GHS HGR HHY AEG',7,'N')
		INSERT INTO cc VALUES (4,DATE(2014,12,12),'ABC ATC',8,'Y')

		SELECT ID,Received,message,Priority,Done,1 as nRow FROM cc INTO CURSOR dd READWRITE
		SELECT dd
		SCAN
			lnRec = RECNO('dd')
			lcFinalText = getlines(ID,ALLTRIM(Message),This.nColumnWidth)
			GO lnRec
			replace message WITH lcFinalText
		ENDSCAN 
	ENDPROC
	PROCEDURE Init
		This.grd.Column1.DynamicCurrentControl = "IIF(ee.nRow = 1,'text1','')"
		This.grd.Column2.DynamicCurrentControl = "IIF(ee.nRow = 1,'text1','')"
		This.grd.Column4.DynamicCurrentControl = "IIF(ee.nRow = 1,'text1','')"
		This.grd.Column5.DynamicCurrentControl = "IIF(ee.nRow = 1,'text1','')"
	ENDPROC
ENDDEFINE


P.S. You can use RecordSourceType = 1 if you create and index, instead of select ... order by Id,nRow

Function getlines inspired by http://www.tek-tips.com/viewthread.cfm?qid=1739736

Respectfully

ENTIRE THREAD

Grid text wrapping Posted by chaim dudi @ 12/28/2014 12:36:56 PM
RE: Grid text wrapping Posted by Mike Gagnon @ 12/28/2014 12:49:08 PM
RE: Grid text wrapping Posted by Vilhelm-Ion Praisach @ 12/28/2014 7:41:53 PM