REALBasic - 以编程方式创建控件
我试图以编程方式创建一些标签,代码不会返回任何错误,但我在窗口中看不到任何标签。
dim dr As DatabaseRecord
dim sql As String
sql = "SELECT * FROM pack WHERE applicabilita_modello LIKE '%" + versione + "%'"
dim rs As RecordSet = database.SQLSelect(sql)
dim i As Integer = 1
dim test(10) As Label
while not rs.EOF
test(i) = new Label
test(i).Text = rs.Field("descrizione").StringValue
test(i).Left = me.Left
test(i).Top = me.Top * i
test(i).Enabled = true
test(i).Visible = true
rs.MoveNext
i = i + 1
wend
rs.Close
我已经验证记录集包含一些数据,循环工作正常,但没有显示标签,无法理解原因。
感谢您的帮助
i'm tring to create some label programmatically, the code doesn't return any error but i cannot see any label in my window.
dim dr As DatabaseRecord
dim sql As String
sql = "SELECT * FROM pack WHERE applicabilita_modello LIKE '%" + versione + "%'"
dim rs As RecordSet = database.SQLSelect(sql)
dim i As Integer = 1
dim test(10) As Label
while not rs.EOF
test(i) = new Label
test(i).Text = rs.Field("descrizione").StringValue
test(i).Left = me.Left
test(i).Top = me.Top * i
test(i).Enabled = true
test(i).Visible = true
rs.MoveNext
i = i + 1
wend
rs.Close
i've verified that the recordset contain some data, the loop work correctly but no label is shown and cannot understand why.
thanks for any help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 Real Studio 中运行时创建控件有两种方法。首先是创建一个控制数组。您可以将该控件命名为 MyLabel 并为其指定零索引。那么你的代码将是:
第二个是使用 ContainerControl。该容器将包含一个标签,因为您可以使用 NEW 命令并使用 ContainerControl.EmbedWithin 方法将它们添加到窗口(或其他容器)。
我通常更喜欢 ContainerControl 方法,原因有很多,但主要是因为控制数组使逻辑变得更加复杂。容器的唯一缺点是它需要 Real Studio Professional 或 Real Studio Enterprise。
http://docs.realsoftware.com/index.php/UsersGuide:Chapter_5:Creating_New_Instances_of_Controls_On_The_Fly < /一>
<一href="http://docs.realsoftware.com/index.php/ContainerControl" rel="nofollow">http://docs.realsoftware.com/index.php/ContainerControl
There are two ways to create controls at runtime in Real Studio. The first is to create a control array. You could name the control MyLabel and give it an index of zero. Then your code would be:
The second is to use a ContainerControl. This container would contain a label and because you can add them to your window (or other container) using the NEW command and using the ContainerControl.EmbedWithin method.
I generally prefer the ContainerControl approach for many reasons, but mostly because control arrays make the logic a big more convoluted. The only drawback with containers is that it requires Real Studio Professional or Real Studio Enterprise.
http://docs.realsoftware.com/index.php/UsersGuide:Chapter_5:Creating_New_Instances_of_Controls_On_The_Fly
http://docs.realsoftware.com/index.php/ContainerControl