Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Wrapping text in grid
Message
De
08/03/2016 06:37:39
 
 
À
07/03/2016 19:08:03
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01632642
Message ID:
01632652
Vues:
75
*this demo code loads a cursor in a grid with textbox support(grid.column..text1)
*if the field is too long relative to its length its transformed on an editbox to edit complet field text.
*in this demo simply click on the grid header to expand/collapse the textbox into editbox or the inverse.
*assuming also have segoe "script" installed(at your choice) .

Publi yform
yform=Newobject("asup")
yform.Show
Read Events
Retu
*
Define Class asup As Form
	Height = 374
	Width = 362
	AutoCenter = .T.
	Caption = "Click on header to expand /hide editbox"
	ycl = .F.
	yrh = .F.
	Name = "Form1"

	Add Object grid1 As Grid With ;
		Height = 361, ;
		Left = 0, ;
		Top = 12, ;
		Width = 360, ;
		Name = "Grid1"

	Procedure my
		Lparameters nButton, nShift, nXCoord, nYCoord
		Sele ycurs
		Thisform.ycl=Iif(Thisform.ycl=.F.,.T.,.F.)

		Do Case
			Case Thisform.ycl=.T.  &&browse editbox
				With Thisform.grid1

					With .Column1
						Try
							.AddObject("yedit","editbox" )  &&if yedit member exits jumps this step
						Catch
						Endtry
						.CurrentControl="yedit"
						.Sparse=.F.
						With .yedit
							.Height=95
							.Parent.Parent.RowHeight=95
							.Value=.Parent.text1.Value
							.FontName="segoe script"
							.forecolor=255
							.fontbold=.t.
							.Visible=.T.
						Endwith
					Endwith
					.Refresh
				Endwith

			Case Thisform.ycl=.F.  && browse textbox
				With Thisform.grid1
					With .Column1
						.RemoveObject("yedit")
						.CurrentControl="text1"
						.Sparse=.F.
						DoDefault()
						With .text1
							.Height=Thisform.yrh
							.Parent.Parent.RowHeight=Thisform.yrh
							.Visible=.T.
						Endwith
						.Refresh
					Endwith
				Endwith

		Endcase
	Endproc

	Procedure Init
		With Thisform.grid1
			.RecordSource="ycurs"
			.RecordSourceType=2
			.Column1.Width=350
			.Anchor=15
			.DeleteMark=.F.
			.GridLines=0
			.RowHeight=20
			.Parent.yrh=.RowHeight
			.Themes=.F.
			.FontName="arial"
			.SetAll("backcolor",0,"header")
			.SetAll("forecolor",Rgb(0,255,0),"header")
			.SetAll("fontbold",.T.,"header")
			.SetAll("DynamicBackColor","IIF(MOD(RECNO( ), 2)=0, RGB(212,208,200), RGB(140,255,100))", "Column")
			Locate
		Endwith
		Bindevent(Thisform.grid1.Column1.header1,"mousedown",Thisform,"my")
	Endproc

	Procedure Load
		Create Cursor ycurs (comments c(250))
		Local m.myvar

		For i=1 To 20
			TEXT to m.myvar textmerge noshow
		<<trans(i)>>. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin vel risus eget lorem feugiat
		fermentum nec a turpis. Phasellus purus sem, mollis ac posuere eget, ornare vel orci. Sed ac rutrum
		nulla.
		*end
			ENDTEXT
			Insert Into ycurs Values (m.myvar)
		Endfor
		*brow
		Locate
	Endproc

	Procedure Destroy
		Clea Events
	Endproc

Enddefine
*
*-- EndDefine: asup
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform