Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7549963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:05:31+00:00 2026-05-30T10:05:31+00:00

How do I get the SuspendLayout and ResumeLayout to work correctly in regards to

  • 0

How do I get the SuspendLayout and ResumeLayout to work correctly in regards to a listview. I have added these lines of code before and after I have added the items, yet each item is still being displayed as I add each item.

thanks

  • My code:

        Dim x As Integer
    
    Dim startTick As Integer = Environment.TickCount
    
    lstFiles.SuspendLayout()
    
    For x = 0 To UBound(cacheListArray)
        If cacheListArray(x) Like "*.txt" Then
            lstFiles.Items.Add(cacheListArray(x))
        End If
    Next
    
    lstFiles.ResumeLayout()
    
    MsgBox(Environment.TickCount - startTick)
    

I am adding 2000 items. This takes 7 seconds. I was told that it should be a lot shorter than that. Is that correct?


New code:

        Dim ListViewItemArray(-1) As ListViewItem

                ReDim Preserve ListViewItemArray(UBound(ListViewItemArray) + 1)
            ListViewItemArray(UBound(ListViewItemArray)).Text = file.Name
            ListViewItemArray(UBound(ListViewItemArray)).SubItems.Add(file.FullName)
            ListViewItemArray(UBound(ListViewItemArray)).SubItems.Add(file.Length)
            ListViewItemArray(UBound(ListViewItemArray)).SubItems.Add(file.CreationTime)
            ListViewItemArray(UBound(ListViewItemArray)).SubItems.Add(file.LastWriteTime)
            ListViewItemArray(UBound(ListViewItemArray)).SubItems.Add(file.LastAccessTime)

        lstFiles.Items.AddRange(ListViewItemArray)

Nothing is being added. What have I done incorrectly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T10:05:33+00:00Added an answer on May 30, 2026 at 10:05 am

    You are using the wrong method. The Suspend/ResumeLayout() methods are only appropriate for container controls whose child controls you want to move around without them getting repainted while you are doing so. You never give ListView any child controls.

    Use the Begin/EndUpdate() methods instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get the memberOf property for my user using this code: DirectorySearcher search =
I have a problem with getting scrollbar positions. Is it possible to get the
Get location(lat/long) without GPS, just like my location feature in Google maps. I have
Get this simple python code, same matching with re.compile instance. I noticed that even
Get all alarms saved in the alarm application here I have read there is
Get an empty HTML, type in this and see its source code on Google
I get Compiler Error C2248 when i try to compile the following code: #include
//get var of posted info so user does not //have to reinsert if if
get / and inside controller I have action that depends on browser When I
get an array of bluetooth ID's Broadcast the bluetooth signal manually

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.