Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calculate Grid Width
Message
From
25/07/2019 07:46:53
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
25/07/2019 06:09:43
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01669732
Message ID:
01669736
Views:
56
>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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform