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 8621535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:50:35+00:00 2026-06-12T06:50:35+00:00

I have a form (Form1) and it has 30 controls. When I hit a

  • 0

I have a form (Form1) and it has 30 controls.
When I hit a button, I want to remove those 30 buttons and put other controls on the form.
Now, my problem is that this is to slow.

I have this list with controls I want to delete and I run through them with a For Each.

Private Sub ClearControls()
    'removing the controls from Me.Controls
    For Each Control As Control In ListToDelete
        Me.Controls.Remove(Control)
    Next
    ListToDelete = New List(Of Control)
End Sub

Now, if you watch the form, you see the controls getting deleted 1 by 1. This action takes about 0.4 seconds (timed with the build-in stopwatch) and that’s too long.

Are there any solutions to delete the controls in a faster way or is it only possible to delete the controls 1 by 1?

Maybe an important fact is that everything is connected with a database.
The controls are created by a class I defined myself (TableDrawer) and it creates a rectangle or circle (depends on info from the database).
I add the selfmade controls to the form and when I want to delete them, it takes 0.4 seconds to get other controls on the form – also with information out of my database.

Hopefully this clears some things up and I hope you can help me out… It really has to go a bit faster (I hope to get 0.1s or lower)

  • 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-06-12T06:50:36+00:00Added an answer on June 12, 2026 at 6:50 am

    Hiding the Panel first seems to make the controls disappear quicker than just clearing the Panel. See this code:

    Option Strict On
    
    Public Class Form1
    
        Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
            Panel1.Visible = False
    
            If Not Panel1.Controls.OfType(Of Button).Any() Then
                For x As Integer = 1 To 10
                    For y As Integer = 1 To 10
                        Dim btn As New Button()
                        btn.Size = New Size(45, 45)
                        btn.Location = New Point((x - 1) * 45, (y - 1) * 45)
                        btn.Text = (x * y).ToString()
                        Panel1.Controls.Add(btn)
                        btn.Visible = True
                    Next
                Next
            End If
    
            Panel1.Visible = True
        End Sub
    
        Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
            Panel1.Visible = False
            Panel1.Controls.Clear()
            Panel1.Visible = True
        End Sub
    End Class
    

    This code has 2 buttons, and a Panel. Button1 generates 100 buttons, places them on a Panel. Button2 hides the panel before removing them. Perhaps you can experiment with this idea.

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

Sidebar

Related Questions

I have a form which has only tab control in it. I want to
I have a form (Form1) that has a NotifyIcon on it. I have another
I have a form, this form has a submit and a cancel button. when
I have a form with 3 textboxes and 1 button. textbox1 has tab index
I have a combobox and button on my form. The combobox has categories in
I have a form with 2 controls on it. Control 1 has several search
We have a form which has a few separate submit buttons which do different
I have a .net 3.5 page which has a form control (form1) and with
I have a form that has a few similar controls and the parent contains
i have a Form which has a button, on the button click event, a

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.