嗨,ListView
我正在插入表格然后将所有内容读回桌子)。ListView
ListView
我在用
listView.Update()
也
listView.Refresh()
但它似乎不起作用。我只是使用SELECT
查询来读取数据datareader
并将其存储在我listView
的如下(正常工作)
唯一的问题是 listView 没有立即刷新,但是当我关闭/打开程序时它可以工作
这是我在 Save 方法末尾使用的代码。基本上这两种方法被调用
Private Sub SetColumns()
Dim lstpenalty As New ListView()
lstpenalty.Items.Clear()
lstpenalty.Visible = True
lstpenalty.Bounds = New Rectangle(New Point(390, 55), New Size(560, 379))
lstpenalty.Name = "lstpenalty"
lstpenalty.FullRowSelect = True
lstpenalty.View = View.Details
lstpenalty.GridLines = True
lstpenalty.Items.Clear()
lstpenalty.Columns.Add("a", 75)
lstpenalty.Columns.Add("b", 70)
lstpenalty.Columns.Add("c", 105)
lstpenalty.Columns.Add("d", 98)
lstpenalty.Columns.Add("e", 90)
lstpenalty.Columns.Add("f", 105)
Me.Controls.Add(lstpenalty)
LoadPenaltyList(lstpenalty)
End Sub
Private Sub LoadPenaltyList(ByRef listView As ListView)
Dim gDR As OracleDataReader
Dim cmd As New OracleCommand
Dim lstpenaltyview As New ListViewItem
Try
cnn.Connect_to_Oper_Agent()
cmd.Connection = cnn.cnn
listView.Items.Clear()
cmd.CommandText = " select a," & _
"b, " & _
"c, " & _
"d," & _
"e," & _
"f" & _
" FROM myTable" & _
" commit"
gDR = cmd.ExecuteReader()
While gDR.Read
lstpenaltyview = listView.Items.Add(Null_To_String(gDR("a")))
lstpenaltyview.SubItems.Add(gDR("b"))
lstpenaltyview.SubItems.Add(gDR("c"))
lstpenaltyview.SubItems.Add(gDR("d"))
lstpenaltyview.SubItems.Add(gDR("e"))
lstpenaltyview.SubItems.Add(gDR("f"))
End While
listView.Update()
Catch ex As Exception
MsgBox("There was an error... -> " & ex.ToString)
Finally
cmd.Dispose()
cnn.Close_Conn()
End Try
End Sub
谢谢你的帮助