在没有记录源的情况下将新行插入网格

时间:2015-06-15 08:22:26

标签: visual-foxpro

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

这是我的代码:

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

感谢有人可以提供帮助。

3 个答案:

答案 0 :(得分:1)

VFP Grid控件显示来自RecordSource的数据,并且该数据始终是&#34;别名&#34;。

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

在您的场景中,Grid.RecordSource可能是您创建的临时表,如果您使用Create Cursor ...命令创建临时表,并避免臭名昭着,您的代码将得到改进&运算符和使用(名称)表达式,而不管你在哪里

答案 1 :(得分:1)

看起来这就是你要做的事情:

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

答案 2 :(得分:0)

现有的5条记录如何进入没有记录源的网格?

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

也许采取这种方法......

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

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

3)刷新网格