2015-06-15 42 views
-1

我有一些問題插入一個新的行行插入到遊標中,然後追加到記錄源。 這就是說我已經在現有的網格列表中有五個記錄,但我需要添加一個新的行到網格列表下一行。插入一行新的行到沒有記錄源的網格

這裏是我的代碼:

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 

欣賞感激有人可以幫助。

回答

0

現有的5條記錄是如何進入沒有記錄源的網格?

你應該更新記錄源而非更新網格控制...

也許採取這種方法...

1)棒數據到陣列或臨時讀寫光標

2 )設置網格記錄源到陣列或光標

3)刷新網格

1

的VFP Grid控制顯示來自其RecordSource的數據,並且該數據總是「別名」。

所以簡單的VFP方式只不過是做一個SQL Insert Into yourAlias ...,或者使用xBase AppendReplace ...命令。

在你的情況下,Grid.RecordSource可能是您創建的臨時表,在這裏,如果你想使用Create Cursor ...命令創建臨時表的代碼會得到改善,並避免臭名昭著&操作和使用(名)表達式,而不是隻要你能

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 
相關問題