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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:56:25+00:00 2026-06-15T06:56:25+00:00

I am having an issue changing runtime generated checkbox names in runtime generated groupboxes.

  • 0

I am having an issue changing runtime generated checkbox names in runtime generated groupboxes. I am using multiple groupboxes, and then taking all of the rows in a database and creating checkboxes for them. The checkbox names are as follows “”chkClass” & intGroupBoxNumber & intCurrentRow”. Upon deletion of a groupbox, I renumber all of the current group boxes, and would like the checkbox names to change as well to the new groupbox number, if this makes any sense. My code is as follows:

strControlName = "grpGroup" & strIBResult
        Try
            intGroupBoxOldYLocation = Me.Controls(strControlName).Location
            Me.Controls(strControlName).Dispose()
            MessageBox.Show("Deleted: " & strControlName)
            intRenameGroup = strIBResult + 1

            Try
                strControlName = "grpGroup" & intRenameGroup
                strControlNewName = "grpGroup" & intRenameGroup - 1
                Me.Controls(strControlName).Location = intGroupBoxOldYLocation
                Me.Controls(strControlName).Text = "Group " & intRenameGroup - 1
                Me.Controls(strControlName).Name = strControlNewName
                MessageBox.Show("Changed: " & strControlName & " to: " & strControlNewName)

                Do While intCurrentClassRow < intTotalClassRows
                    strCheckBoxOldName = "chkClass" & intRenameGroup & intCurrentClassRow
                    strCheckBoxNewName = "chkClass" & intRenameGroup - 1 & intCurrentClassRow
                    MessageBox.Show("Renaming: " & strCheckBoxOldName & " to: " & strCheckBoxNewName)
                    Me.Controls(strCheckBoxOldName).Name = strCheckBoxNewName
                    intCurrentClassRow += 1
                    MessageBox.Show("Renamed: " & strCheckBoxOldName & " to: " & strCheckBoxNewName)
                Loop

                intCurrentClassRow = 0
                intRenameGroup += 1
                intGroupBoxNewYIncrement = intGroupBoxOldYLocation.Y + Me.Controls(strControlNewName).Height + 50

                Do
                    strControlName = "grpGroup" & intRenameGroup
                    strControlNewName = "grpGroup" & intRenameGroup - 1
                    Me.Controls(strControlName).Location = New Point(intCurrentXPosition, intGroupBoxNewYIncrement)
                    Me.Controls(strControlName).Text = "Group " & intRenameGroup - 1
                    Me.Controls(strControlName).Name = strControlNewName

                    Do While intCurrentClassRow < intTotalClassRows
                        strCheckBoxOldName = "chkClass" & intRenameGroup & intCurrentClassRow
                        strCheckBoxNewName = "chkClass" & intRenameGroup - 1 & intCurrentClassRow
                        Me.Controls(strCheckBoxOldName).Name = strCheckBoxNewName
                        intCurrentClassRow += 1
                        MessageBox.Show("Renamed: " & strCheckBoxOldName & " to: " & strCheckBoxNewName)
                    Loop

                    intCurrentClassRow = 0
                    intRenameGroup += 1
                    intGroupBoxNewYIncrement = intGroupBoxNewYIncrement + Me.Controls(strControlNewName).Height + 50
                Loop

            Catch ex As Exception
                MessageBox.Show("Control: " & strControlName & " does not exist")
                MessageBox.Show(ErrorToString)
            End Try

        Catch ex As Exception
            'MessageBox.Show("Control: " & strControlName & " never existed")
            MessageBox.Show("Please enter a valid group number to delete.", "Invalid Entry")
            Exit Sub
        End Try 

I am pretty sure my trouble now exists at the Me.Controls(strCheckBoxOldName).Name = strCheckBoxNewName

The error is as follows: “Object reference not set to an instance of an object”

Is there a different method to reference that runtime generated groupbox?

Thanks. Sorry if this is confusing!

  • 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-15T06:56:26+00:00Added an answer on June 15, 2026 at 6:56 am

    The form’s Controls collection only contains the top-level controls that are placed directly on the form. If you load a control into a container control, such as a GroupBox, you must find it in that container control’s Controls collection.

    So, instead of doing this:

    Me.Controls(strCheckBoxOldName).Name = strCheckBoxNewName
    

    You should be doing something like this:

    Me.Controls(strControlName).Controls(strCheckBoxOldName).Name = strCheckBoxNewName
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having an issue opening, changing, and then saving changes to an XML file using
I am having an issue where NSDictionary is changing the values inside the <data>
Im having a weird issue here; The following .htaccess works but now (after changing
I'm having an issue with changing the attribute for an id and can't seem
Right now the biggest issue I'm having with using AJAX is the fact that
New to jQuery, having an issue with dynamically changing the selector. <html> <head> <script
Having an issue with commas and values. I have a value that keeps changing
I'm having an issue with changing the URL of the page after a form
I am currently having an issue with using a function defined as a const
I am having an issue changing the value of a text box in MVC

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.