如何在listview中设置记录的位置? [英] How can I set the position of a record in listview?

查看:97
本文介绍了如何在listview中设置记录的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Private Sub BtnAdd3_Click()
    Set OBJLIST = ListView1.ListItems.Add(, , Text1.Text)
        OBJLIST.SubItems(1) = Text4.Text
        OBJLIST.SubItems(2) = Text3.Text
        OBJLIST.SubItems(3) = Combo2.Text
        OBJLIST.SubItems(4) = Text5.Text
        OBJLIST.SubItems(5) = Text7.Text
        OBJLIST.SubItems(6) = Text8.Text
        OBJLIST.SubItems(7) = Text9.Text
        OBJLIST.SubItems(8) = Text11.Text
End Sub

Private Sub BtnEdit3_Click()
SQL = "SELECT * FROM [NOTE]"
.Open SQL, CON, 1, 2
For i = 1 To ListView1.ListItems.Count
a = "DOC_NO <>" & ListView1.ListItems(i).Text & ListView1.ListItems(i).ListSubItems(1).Text
.Find a, , adSearchForward

SQL = "INSERT INTO [NOTE](DOC_NO,DOC_SUBNO,AID,QTY,RATE,TOTAL_AMNT,DOC_TYPE,DOC_DATE,REMARK,LOC_ID,SUP_ID) " & _
" VALUES(" & ListView1.ListItems(i).Text & ListView1.ListItems(i).ListSubItems(1).Text & "," & ListView1.ListItems(i).ListSubItems(1).Text & "," & _
"" & ListView1.ListItems(i).ListSubItems(2).Text & "," & ListView1.ListItems(i).ListSubItems(5).Text & "," & _
" " & ListView1.ListItems(i).ListSubItems(6).Text & "," & ListView1.ListItems(i).ListSubItems(7).Text & "," & _
" 'DEBIT','" & DTPicker2.Value & "','" & Text2.Text & "'," & _
" " & Combo4.ItemData(Combo4.ListIndex) & "," & Combo5.ItemData(Combo5.ListIndex) & ")"
    Set RS = CON.Execute(SQL)
Next
End If
End Sub



此代码将数据从ctrl'添加到listview但在最后位置(在列表视图中已经显示所有记录之后)....

当我点击保存按钮,它开始从顶部位置保存记录(这些记录已存在于数据库中)

所以我想保存当前添加的记录在listview的最后位置...

datz y我为< .find>编码,它在listview n中的记录再次保存了具有不同自动编号的现有rec .......

我想跳过现有的rec n只保存那些doc_no + doc_subno是新的....

plz帮帮我....


This code adds data from ctrl''s to listview but at the last position(after all already shown records in listview)....
When I click save button,it starts saving records from top position(which records are already exist in database)
So I want to save the currently added record present at last position in listview...
datz y I coded for <.find>,it''s records in listview n again saves existing rec with different autonumber.......
I want to skip the existing rec n save only those whose doc_no+doc_subno are new....
plz help me....

推荐答案

如果你只想将listview的最后一项添加到数据库中(你的问题不清楚)那么

  • 删除对于 loop
  • 设置i = ListView1.ListItems.Count-1
If you want to add just the last item of the listview to the database (your question is not clear) then
  • Remove the For loop
  • set i = ListView1.ListItems.Count-1


    这篇关于如何在listview中设置记录的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆