반응형

* VBNET Listview 데이터 조회 BeginUpdate , EndUpdate 예제

 

Main

 

 

-사용한 컨트롤: Button 2개, Listview 1개

 

전체 소스 코드

Form1.vb

 

Public Class Form1

    Dim dtStart As DateTime

    Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
        'Listview Search
        listView1.Items.Clear()

        dtStart = DateTime.Now

        Dim i As Integer
        For i = 0 To 30000 - 1 Step i + 1
            Dim lvi As ListViewItem = New ListViewItem()
            lvi.Text = (i + 1).ToString()
            lvi.SubItems.Add("TEST " + (i + 1).ToString())
            listView1.Items.Add(lvi)
        Next

        MessageBox.Show(After_Time(DateTime.Now, dtStart).ToString() + " 초")
    End Sub

    Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button2.Click
        'ListView Search Begin End Update
        listView1.Items.Clear()

        dtStart = DateTime.Now

        listView1.BeginUpdate()
        Dim i As Integer
        For i = 0 To 30000 - 1 Step i + 1
            Dim lvi As ListViewItem = New ListViewItem()
            lvi.Text = (i + 1).ToString()
            lvi.SubItems.Add("TEST " + (i + 1).ToString())
            listView1.Items.Add(lvi)
        Next
        listView1.EndUpdate()

        MessageBox.Show(After_Time(DateTime.Now, dtStart).ToString() + " 초")
    End Sub

    Private Function After_Time(ByVal dtNow As DateTime, ByVal dtBefore As DateTime) As Double
        Dim ts As TimeSpan = dtNow - dtBefore
        Return ts.TotalSeconds
    End Function

End Class

 

 

*예제 결과

 

- Begin End 사용하기 전

 

- Begin End 사용 후




반응형

+ Recent posts