adding control at prevCon.Bottom but the gap keeps doubling
I am adding controls to a form like this
Dim sharpUserX As New SharpUser()
Dim y As Integer = 0
For Each con As Control In PnlSharpUsers.Controls
If TypeOf(con) is SharpUser then ' as i have the pnaddbtn, which i
move to the bottom below
If y < con.Bottom Then y = con.Bottom
End If
Next
sharpUserX.Location = New Point(2, y)
'sharpUserX.Location = pnlAddBtn.location 'this does that exact same
sharpUserX.Size = sharpUserSize
PnlSharpUsers.Controls.Add(sharpUserX)
'put add button back on
pnlAddBtn.Location = New Point(pnlAddBtn.Left, sharpUserX.Bottom)
'strangely this is always correct
This is called on a button press, which adds a ShrpUser control to my
panel, and then moves the addbtn panel to the bottom.
The add btn panel moves correctly, but the new control added gets added,
but the location seems to double the difference of the gap from it to the
previous control.
Heres the locations if i output them after each add
1 added
loc={X=2,Y=0} size={Width=849, Height=117}
2nd added
loc={X=2,Y=0} size={Width=849, Height=117}
loc={X=2,Y=135} size={Width=849, Height=117}
3rd added
loc={X=2,Y=0} size={Width=849, Height=117}
loc={X=2,Y=135} size={Width=849, Height=117}
loc={X=2,Y=291} size={Width=849, Height=117}
y on 2 should be 117 and y on 3 should be 234 the form does scale by font.
Im thinking this is whats causing it, but i cant figure out what to do,
and cant understand why the pnladdBtn works.
No comments:
Post a Comment