Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calculate Grid Width
Message
De
25/07/2019 10:53:27
 
 
À
25/07/2019 07:46:53
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01669732
Message ID:
01669740
Vues:
53
Yes, that would be a question. In the hurry I wrote incorrectly.
Excuse me - my mistake
why + 25?

>Hi,
>Grid is located in the container. Grid has n fields.
>how to calculate the width of a grid ?
>
>This is short example,but...
>
>ukkolw=0
>
>FOR lnCnt = 1 TO loObject.ColumnCount
>
> loCol = loObject.Columns[lnCnt]
> loCol.RemoveObject( loCol.Controls[2].Name )
> loCol.AddObject( "TXTGRIDSEARCH1", "TXTGRIDSEARCH" )
> loCol.ReadOnly = .T.
>
> ukkolw = ukkolw + loCol.Width
>
>ENDFOR
>
>Thanks

Looks like you are not asking grid's width which is simply oGrid.Width, but asking what would be the total width of columns? If so:
Local ix, tWidth, nParentWidth
tWidth = 0
With oGrid
	For ix=1 To .ColumnCount
		With .Columns(m.ix)
			tWidth = m.tWidth + .Width
		Endwith
	Endfor


	nParentWidth = Iif(.Parent.BaseClass == "Page", .Parent.Parent.Width, .Parent.Width)
	If m.tWidth + 25 +.Left > m.nParentWidth - (.Left+1)
		.Width = m.nParentWidth - (.Left+1)
	Else
		.Width = m.tWidth + 25
		.ScrollBars = 2
	Endif
Endwith
PS: This code is extracted and modified from LocatorGrid class' Init method, which is in Grids.vcx of FoxyClasses. You can download and use FoxyClasses from below link if you want to (it comes with all the source code that you can read or modify) - and LocatorGrid might simply be what you are trying to do, check its samples and help.

https://drive.google.com/open?id=1s5kfyL-LP8X2EJqwI7K-TPLzR69yzbjP
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform