【问题标题】:insert a new line of row into grid without recordsource在没有记录源的情况下将新行插入网格
【发布时间】:2015-06-15 08:22:25
【问题描述】:

我在将新行插入记录而不插入游标然后追加到记录源时遇到了一些问题。 也就是说,我在现有网格列表中已经有 5 条记录,但我需要在网格列表下的下一行添加新行。

这是我的代码:

vc_tmpfile = alltrim(sys(3)) + ".dbf"

create table &vc_tmpfile (text c(254))

append from C:\tmp\aaa.out type sdf

dele all for len(ALLTRIM(text)) < 15

pack

with thisform.grid_list

  Do while !EOF()


     if alltrim(substr(text,1,4)) == "POPL"

         .columns(2).text1.value = alltrim(substr(text,6,6))--->>It shows nothing after insert

     endif

   skip
  enddo

endwith

感谢有人可以提供帮助。

【问题讨论】:

    标签: visual-foxpro


    【解决方案1】:

    VFP Grid 控件显示来自其RecordSource 的数据,并且该数据始终是“别名”。

    因此,简单的 VFP 方法就是执行 SQL Insert Into yourAlias ...,或使用 xBase AppendReplace ... 命令。

    在您的场景中,Grid.RecordSource 可能是您创建的临时表,如果您使用 Create Cursor ... 命令创建临时表并避免使用臭名昭著的 &amp; 运算符,您的代码将会得到改进并尽可能使用 (name) 表达式

    【讨论】:

      【解决方案2】:

      看起来这就是你想要做的:

      thisform.grid_list.RecordSource = ''
      vc_tmpfile = Sys(2015)
      Create cursor (m.vc_tmpfile) (text c(254))
      append from ('C:\tmp\aaa.out') type sdf for len(ALLTRIM(text)) >= 15
      Update (m.vc_tmpFile) set text = alltrim(substr(text,6,6)) where text like "POPL%"
      locate
      thisform.grid_list.RecordSource = m.vc_tmpfile
      

      【讨论】:

        【解决方案3】:

        现有的 5 条记录是如何在没有记录源的情况下进入网格的?

        您应该更新记录源而不是更新网格控件...

        也许采取这种方法...

        1) 将数据粘贴到数组或临时读写游标中

        2) 将网格记录源设置为数组或光标

        3) 刷新网格

        【讨论】:

          猜你喜欢
          • 2019-08-19
          • 1970-01-01
          • 2021-11-26
          • 1970-01-01
          • 2023-03-31
          • 2022-12-03
          • 2013-04-05
          • 1970-01-01
          • 2013-02-16
          相关资源
          最近更新 更多