Why aren't you simply take the left value of the previous cell + the width of the previous cell?
You are looping and adding (in iRetVal) all the Left properties of each cells!
>I'v created a usercontrol called Cell. I'v also created a usercontrol called Row.
>A Row can contain one or more Cells, aligned across the row one right after each
>other. A Grid would therefore contain one or more Row controls.
>
>I'm having a problem positioning the cells. This code
should work, but
>the last cell is off by the width of itself.
>
>Hope that was clear. Heres the code:
>
>Private Function GetNextCellLeftPosition() As Integer
>
> Dim iCell As Integer
> Dim iRetVal As Integer
>
> iRetVal = 0
>
> For iCell = 0 To RowCells.Count - 1
>
> If iCell = 0 Then
> iRetVal = 0
> Else
> iRetVal = iRetVal + RowCells(iCell - 1).Left + RowCells(iCell - 1).Width
> End If
>
> Next
>
> GetNextCellLeftPosition = iRetVal
>
>End Function
>
>
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com