If beforebtnslength > Activity.Width Then
ycounter = ycounter + 1
beforebtnslength = 0
Else If beforebtnslength + SQLReader.GetString("name").Length*3%x > Activity.Width Then
ycounter = ycounter + 1
beforebtnslength = 0
Else
xcounter = xcounter + 1
End If
'cPanel is fpanel or spanel, depends on where I want to write'
'btn is a label'
cPanel.AddView(btn, beforebtnslength, ycounter * (50dip), 1%x ,2%y)
'cvsTest is canvas'
cvsTest.Initialize(btn)
btn.Height = cvsTest.MeasureStringHeight(btnText, Typeface.DEFAULT, 40)
btn.Width = cvsTest.MeasureStringWidth(btnText, Typeface.DEFAULT, 30) + 10dip
beforebtnslength = btn.Width + beforebtnslength + 10dip