Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calculate Grid Width
Message
From
25/07/2019 14:35:52
 
 
To
25/07/2019 10:53:27
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01669732
Message ID:
01669748
Views:
61
I'm guessing that's to account for the width of the vertical scrollbar (perhaps we should query the system metrics for this if this is the case).

In any case, at least it's not as ugly as the code I was using to fake grids in FoxPro DOS and FoxPro Windows (the FoxPro DOS was simpler due to being character-based). It involved having windows within windows within windows (the first level child acting as a "clipping region" and "grandchild" was the actual browse or window that contains the controls for the form).

>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
Previous
Reply
Map
View

Click here to load this message in the networking platform