本文介绍了使用计时器输入新记录时重新加载listiview项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 嘿..检查数据库是否有新的输入记录是否可行?如果检测到一个..列表视图将被重新设置?我试图创建这种功能,但它对我不起作用,我有以下代码 private sub list_load()''这是用于重新加载listview项目 dim strsql as string dim rsload as new adodb.recordset dim x as integer dim list as listviewitem strsql =select * from customer''这只是一个示例查询 with rsload .open(strsql,conn) do .eof = false list = lstcustomer.items.add(.fields(0 )。值) for x = 1到3步1 list.subitems(x).text = .fields(x).value next x .movenext loop .close 结束 end sub ''这将是计时器的代码--------------------- - dim strsql as string dim rsload as n ew adodb.recordset dim count as integer dim counthandler as integer x: strsql =select count(*)as total from customer with rsload .open(strsql,conn) 如果.eof = false那么 count = .fields(total)。value 如果counthandler =什么,那么 counthandler = count + 1 else ''什么都不做 结束如果 endif .close 结束 如果coumthandler = count那么 调用list_load''调用list_load子 else ''没有什么 endif 转到x ----------------------- ----------------------- 问题是代码不能工作..我的项目只是挂起。并且代码的目的是我尝试局域网连接。当lan项目输入新记录时,主项目应检测到已添加新记录,如果检测到新记录,则应再次自动重新加载listview项目。 如果我只是使用计时器每1,2,3秒重新加载listview项目会很容易,但我认为创建一个代码来检查是否有新记录输入会很好.. 请帮忙,提前谢谢.. :) 解决方案 hey.. is it posible to check if database have new inputed records? and if detected one.. the listview would be reloted? i have tried to create that kind of function but it doesnt work for me, i have the codes belowprivate sub list_load() ''this is for reloading listview items dim strsql as string dim rsload as new adodb.recordset dim x as integer dim list as listviewitem strsql = "select * from customer" ''this is just a sample query with rsload .open (strsql,conn) do while .eof = false list = lstcustomer.items.add(.fields(0).value) for x = 1 to 3 step 1 list.subitems(x).text = .fields(x).value next x .movenext loop .close end withend sub''this will be the code for the timer-----------------------dim strsql as stringdim rsload as new adodb.recordsetdim count as integerdim counthandler as integerx:strsql = "select count(*) as total from customer"with rsload .open (strsql,conn) if .eof = false then count = .fields("total").value if counthandler = nothing then counthandler = count + 1 else ''do nothing end if endif .closeend withif coumthandler = count then call list_load ''calls the list_load subelse ''no nothingendifgoto x----------------------------------------------the problem is that the code wont work.. my project just hangs. and the purpose of the code is that im trying a lan connection. whenever lan project enters new record, the main project should detect that new record has been added, and if it detects one the listview items should be automatically reloaded again. it would be easy if i just reload listview items every 1,2,3 seconds using a timer, but i think creating a code for checking if new record has been entered would be good..please help, advance thanks..:) 解决方案 这篇关于使用计时器输入新记录时重新加载listiview项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
11-02 02:02