Suspend Layout Problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm filling a listbox with a zillion rows from a database. I'm executing a
background thread to add to the underlying DataTable so the user does not
have to wait.

The problem is this - the Listbox still seems to flicker as it is filled.
Is there a way to stop this?

Private Sub continuefilling(ByVal Thing As Object)

Do
Me.ListBox1.SuspendLayout()
Dim SQL As String = "Select top 10 ID, Account From Accounts
where ID > " + LastAccountID.ToString + " order by account"
Dim DT2 As DataTable = DB.GetDataSet(SQL).Tables(0)
If DT2.Rows.Count = 0 Then Return
LastAccountID = CInt(DT2.Rows(DT2.Rows.Count - 1)("ID"))
For Each r As DataRow In DT2.Rows
DT.ImportRow(r)
Next
Me.ListBox1.ResumeLayout()
Loop

End Sub
 
Never mind, found it myself... BeginUpdate and EndUpdate instead of
SuspendLayout...

-zorpy
 
Use BeginUpdate and EndUpdate instead of SuspentLayout/ResumeLayout.

HTH,

Sam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top