REALBasic - 以编程方式创建控件

发布于 2024-12-10 00:22:13 字数 592 浏览 2 评论 0原文

我试图以编程方式创建一些标签,代码不会返回任何错误,但我在窗口中看不到任何标签。

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

贩梦商人 2024-12-17 00:22:13

在 Real Studio 中运行时创建控件有两种方法。首先是创建一个控制数组。您可以将该控件命名为 MyLabel 并为其指定零索引。那么你的代码将是:

test(i) = new 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:

test(i) = new MyLabel

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文