It has been a very long time to remember how I reasoned to that 25. But believe me, if I could find a way to calculate it using things like sysmetric, then I would use that. All I know, I am using that class heavily since years, and the grids are fitting very well inside their containers.
>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