使用文件 vb6 填充 flexgrid

发布于 2024-08-27 21:41:49 字数 346 浏览 12 评论 0原文

所以我需要将文件中的所有名称放入 flexgird 上的第 1 列中,每个名称应该放在自己的行上。这是我所拥有的,但我只是得到“无效的行值”

namefile = App.Path & "\names.dat"
Open namefile For Input As #1
While Not EOF(1)
    Input #1, x
        With MSFlexGrid1
            .Col = 1
            .Rows = rowcount + 1
            .Text = x
        End With
Wend
End Sub

任何帮助都会很棒,并提前致谢

So I need to put all the names in a file into column 1 on flexgird, each name should go on its own row. here is what I have but i just get "invalid row value"

namefile = App.Path & "\names.dat"
Open namefile For Input As #1
While Not EOF(1)
    Input #1, x
        With MSFlexGrid1
            .Col = 1
            .Rows = rowcount + 1
            .Text = x
        End With
Wend
End Sub

Any help would be fantastic and thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

木緿 2024-09-03 21:41:49

我不确定为什么 rowcount 出现在您的示例代码中,但这对我有用

namefile = App.Path & "\names.dat"
Open namefile For Input As #1
MSFlexGrid1.Rows = 1
MSFlexGrid1.Col = 1
While Not EOF(1)
    Input #1, x
    With MSFlexGrid1
       .Rows = .Rows + 1
       .Row = .Rows - 1
       .Text = x
    End With
Wend
End Sub

我还将 .Col =1 从循环中取出 - 您不需要继续设置它并且你的循环会比没有它更快(不是很多,但重复设置它是没有意义的)

I'm not sure why rowcount is in your example code, but this works for me

namefile = App.Path & "\names.dat"
Open namefile For Input As #1
MSFlexGrid1.Rows = 1
MSFlexGrid1.Col = 1
While Not EOF(1)
    Input #1, x
    With MSFlexGrid1
       .Rows = .Rows + 1
       .Row = .Rows - 1
       .Text = x
    End With
Wend
End Sub

I've also pulled the .Col =1 out of your loop - you don't need to keep setting it and your loop will be faster than without it (not by much but repeatedly setting it is pointless)

浊酒尽余欢 2024-09-03 21:41:49

如何将 Recordset 的内容转储到 Flexgrid 中。

加载任何内容后是记录集,本文提供了有关您想要使用网格执行的各种操作的技术。

How to dump contents of the Recordset into a Flexgrid.

Once you load whatever it is into a recordset, this article provides techniques on various things you'll want to do with the grid.

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