how hide slow visual updates to bound listbox

In the code attached there is a brief delay in refreshing the listbox contents.  During the time between the datasource being assigned and the display member and value member being assigned, the listbox displays the class names to the user.   I've tried to Hide and Show the listbox in that time, but my perception is the user would find that even more annoying.   How can I prevent the listbox from displaying the name of the class to the user?  (The listbox is bound to a bindingsource which is in turn bound to a datasouce of a list of the class.)

Public Sub MoveSelection(ByVal strdirection As String)

        Dim ndx As Integer = 0
        Dim pfc As PageFileClass = Nothing
        pfc = frm.ListBoxPageFiles.SelectedItem
        Dim fc As HPFFAFormClass = Nothing
        Dim cnt As Integer = 0
        Dim newindex As Integer = 0
        Try

            If strdirection.ToUpper = "UP" Then
                If pfc Is Nothing Then Return

                ndx = frm.ListBoxPageFiles.Items.IndexOf(pfc)


                If ndx = 0 Then
                    Return
                End If

                pg_bs.RemoveAt(ndx)
                pg_bs.Insert(ndx - 1, pfc)

                newindex = ndx - 1

            ElseIf strdirection.ToUpper = "DOWN" Then

                If pfc Is Nothing Then Return

                ndx = frm.ListBoxPageFiles.Items.IndexOf(pfc)

                If ndx = frm.ListBoxPageFiles.Items.Count - 1 Then
                    Return
                End If

                If ndx = -1 Then
                    Return
                End If
                pg_bs.RemoveAt(ndx)
                pg_bs.Insert(ndx + 1, pfc)
                newindex = ndx + 1


            End If

            frm.ListBoxPageFiles.DataSource = Nothing
            frm.ListBoxPageFiles.DataSource = pg_bs
            frm.ListBoxPageFiles.DisplayMember = "PageName"
            frm.ListBoxPageFiles.ValueMember = "Pageno"
            frm.ListBoxPageFiles.SelectedIndex = newindex

        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical, HPFMain.TitleBar)
        End Try

    End Sub

Open in new window

codefingerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CodeCruiserCommented:
Change the sequence from

            frm.ListBoxPageFiles.DataSource = Nothing
            frm.ListBoxPageFiles.DataSource = pg_bs
            frm.ListBoxPageFiles.DisplayMember = "PageName"
            frm.ListBoxPageFiles.ValueMember = "Pageno"


to

            frm.ListBoxPageFiles.DataSource = Nothing
            frm.ListBoxPageFiles.DisplayMember = "PageName"
            frm.ListBoxPageFiles.ValueMember = "Pageno"
            frm.ListBoxPageFiles.DataSource = pg_bs
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
codefingerAuthor Commented:
Much better!  Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.