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

  • Home
  • SEARCH
  • 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 9321641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:53:39+00:00 2026-06-19T03:53:39+00:00

I have a movie theater seating project that dynamically creates checkboxes as seats. I

  • 0

I have a movie theater seating project that dynamically creates checkboxes as seats. I dynamically create labels across the top and down the right side of the checkboxes that represents the seats (alpha) and rows (numbers). Currently I have numbers across the top and I want letters i.e. A, B, C, D.

Here is my code

Public Class frmSeating
    ' Declare two dynamic arrays to store the created CheckBox and Label
    ' control instances. The array named chkSeats is a 2-dimensional array
    ' and the array lblRow is a one dimensional array.
    Private chkSeats(,) As System.Windows.Forms.CheckBox
    Private lblRow() As System.Windows.Forms.Label
    Private lblSeat() As System.Windows.Forms.Label

    ' The following constants improve readibility by defining the
    ' standard size of each check box, and the number of seats and rows
    ' for each airplane type.
    Private Const cintCheckBoxHeight As Integer = 23
    Private Const cintCheckBoxWidth As Integer = 23

    Private Const cintABCSeats As Integer = 20
    Private Const cintABCRows As Integer = 20

    Private Const cintCBSSeats As Integer = 26
    Private Const cintCBSRows As Integer = 30

    Private Const cintNBCSeats As Integer = 10
    Private Const cintNBCRows As Integer = 25

    ' The variables mintFull and mintEmpty store the number of
    ' occupied and empty seats in the theater.
    Private mintFull As Integer
    Private mintEmpty As Integer

    ' pntCurrent is used to create a Point structure.
    Private pntCurrent As System.Drawing.Point

    ' All of the work takes place in the ConfigureSeating procedure. This
    ' procedure is called by the constructor. See the New procedure in the
    ' Windows Form Designer generated code.
    Private Sub ConfigureSeating(ByVal TheaterType As String)

        ' Variables to store the current seat and the current row.
        Dim pintSeatCurrent, pintRowCurrent As Integer

        ' The Select Case statement configures the airplane based on the
        ' type of airplane. This value is passed to the procedure, and is
        ' obtained from the argument passed through the constructor.
        Select Case TheaterType


            Case "ABC Theater"
                ' Redimension the arrays containing the check boxes and 
                ' labels based on the current Theater configuration.
                ReDim chkSeats(cintABCSeats, cintABCRows)
                ReDim lblRow(cintABCRows)
                ReDim lblSeat(cintABCSeats)

                ' Define the number of empty seats.
                mintEmpty = cintABCSeats * cintABCRows

                ' Create each check box representing a seat.
                For pintSeatCurrent = 0 To cintABCSeats - 1
                    For pintRowCurrent = 0 To cintABCRows - 1
                        pntCurrent = New Point((pintSeatCurrent + 1) * cintCheckBoxWidth, _
                            (pintRowCurrent + 1) * cintCheckBoxHeight)
                        Call CreateCheckBox(pintSeatCurrent, pintRowCurrent, pntCurrent)
                    Next
                Next

                'Create the labels to identify the rows.
                For pintRowCurrent = 0 To cintABCRows - 1
                    Call CreateRowLabel(pintRowCurrent)
                    lblRow(pintRowCurrent).Left = 490
                    lblRow(pintRowCurrent).Top = (pintRowCurrent + 1) * cintCheckBoxHeight
                    lblRow(pintRowCurrent).Height = 15
                    lblRow(pintRowCurrent).Width = 25
                Next
                'Create the labels to identify the columns
                For pintSeatCurrent = 0 To cintABCSeats - 1
                    Call CreateSeatLabel(pintSeatCurrent)
                    lblSeat(pintSeatCurrent).Left = (pintSeatCurrent + 1) * cintCheckBoxHeight
                    lblSeat(pintSeatCurrent).Top = 1
                    lblSeat(pintSeatCurrent).Height = 15
                    lblSeat(pintSeatCurrent).Width = 25
                Next

            Case "CBS Theater"

                ReDim chkSeats(cintCBSSeats, cintCBSRows)
                ReDim lblRow(cintCBSRows)
                ReDim lblSeat(cintCBSSeats)

                mintEmpty = cintCBSSeats * cintCBSRows

                For pintSeatCurrent = 0 To cintCBSSeats - 1
                    For pintRowCurrent = 0 To cintCBSRows - 1
                        pntCurrent = New Point((pintSeatCurrent + 1) * cintCheckBoxWidth, _
                            (pintRowCurrent + 1) * cintCheckBoxHeight)
                        Call CreateCheckBox(pintSeatCurrent, pintRowCurrent, pntCurrent)
                    Next
                Next

                For pintRowCurrent = 0 To cintCBSRows - 1
                    Call CreateRowLabel(pintRowCurrent)

                    lblRow(pintRowCurrent).Left = 625
                    lblRow(pintRowCurrent).Top = (pintRowCurrent + 1) * cintCheckBoxHeight
                    lblRow(pintRowCurrent).Height = 15
                    lblRow(pintRowCurrent).Width = 25
                Next

                For pintSeatCurrent = 0 To cintCBSSeats - 1
                    Call CreateSeatLabel(pintSeatCurrent)
                    lblSeat(pintSeatCurrent).Left = (pintSeatCurrent + 1) * cintCheckBoxHeight
                    lblSeat(pintSeatCurrent).Top = 1
                    lblSeat(pintSeatCurrent).Height = 15
                    lblSeat(pintSeatCurrent).Width = 25
                Next

            Case "NBC Theater"

                ReDim chkSeats(cintNBCSeats, cintNBCRows)
                ReDim lblRow(cintNBCRows)
                ReDim lblSeat(cintNBCSeats)

                mintEmpty = cintNBCSeats * cintNBCRows

                For pintSeatCurrent = 0 To cintNBCSeats - 1
                    For pintRowCurrent = 0 To cintNBCRows - 1
                        pntCurrent = New Point((pintSeatCurrent + 1) * cintCheckBoxWidth, _
                            (pintRowCurrent + 1) * cintCheckBoxHeight)
                        Call CreateCheckBox(pintSeatCurrent, pintRowCurrent, pntCurrent)
                    Next
                Next

                For pintRowCurrent = 0 To cintNBCRows - 1
                    Call CreateRowLabel(pintRowCurrent)

                    lblRow(pintRowCurrent).Left = 255
                    lblRow(pintRowCurrent).Top = (pintRowCurrent + 1) * cintCheckBoxHeight
                    lblRow(pintRowCurrent).Height = 15
                    lblRow(pintRowCurrent).Width = 25
                Next

                For pintSeatCurrent = 0 To cintNBCSeats - 1
                    Call CreateSeatLabel(pintSeatCurrent)
                    lblSeat(pintSeatCurrent).Left = (pintSeatCurrent + 1) * cintCheckBoxHeight
                    lblSeat(pintSeatCurrent).Top = 1
                    lblSeat(pintSeatCurrent).Height = 15
                    lblSeat(pintSeatCurrent).Width = 25
                Next
        End Select

    End Sub

    ' The CreateCheckBox procedure is responsible for actually creating
    ' each CheckBox control instance and adding a reference to the array.
    ' The current seat and row are passed as arguments, along with the 
    ' position of the check box.
    Private Sub CreateCheckBox(ByVal pintSeatCurrent As Integer, ByVal pintRowcurrent As Integer, ByVal pnt As Point)

        ' Create an instance of the CheckBox control and make it visible.
        chkSeats(pintSeatCurrent, pintRowcurrent) = New CheckBox()
        chkSeats(pintSeatCurrent, pintRowcurrent).Visible = True

        ' Define the size of the CheckBox control instance by creating an 
        ' instance of the Size structure and assigning a value to the Size
        ' property.
        chkSeats(pintSeatCurrent, pintRowcurrent).Size = _
            New System.Drawing.Size(cintCheckBoxWidth, cintCheckBoxHeight)

        ' Define the position of the CheckBox control instance.
        chkSeats(pintSeatCurrent, pintRowcurrent).Location = pnt

        ' Add the event handler for the newly created CheckBox control instance. 
        ' The procedure named chkSeats_CheckChanged will handle the CheckedChanged event for
        ' all of the created check boxes.
        AddHandler chkSeats(pintSeatCurrent, pintRowcurrent).CheckedChanged, _
            AddressOf chkseats_CheckedChanged

        ' Finally, add the newly creted CheckBox control instance to the Controls 
        ' collection for the Panel. Note that by adding the control instance to the
        ' Controls collection of the Panel rather than the form, the control instances
        ' will be contained by the Panel. The reason is simple. The CheckBox control
        ' instances will scroll with the Panel instead of the form.
        Me.pnlSeats.Controls.Add(chkSeats(pintSeatCurrent, pintRowcurrent))
    End Sub

    ' The CreateLabel procedure is responsible for actually creating each
    ' Label control instance and adding a reference to the array.
    Private Sub CreateRowLabel(ByVal pintRowCurrent As Integer)
        lblRow(pintRowCurrent) = New Label()
        lblRow(pintRowCurrent).Visible = True
        lblRow(pintRowCurrent).Text = (pintRowCurrent + 1).ToString()
        Me.pnlSeats.Controls.Add(lblRow(pintRowCurrent))
    End Sub

    Private Sub CreateSeatLabel(ByVal pintSeatCurrent As Integer)
        lblSeat(pintSeatCurrent) = New Label()
        lblSeat(pintSeatCurrent).Visible = True
        lblSeat(pintSeatCurrent).Text = (pintSeatCurrent + 1).ToString()
        Me.pnlSeats.Controls.Add(lblSeat(pintSeatCurrent))
    End Sub


    ' The CheckedChanged event handler is a multicast event handler and
    ' handles the CheckedChanged event for all of the CheckBox control instances.
    ' The statements in the event handler update the number of full or empty
    ' seats in the theater.
    Private Sub chkseats_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

        ' Declare a varible to store the CheckBox.
        Dim chkCurrent As System.Windows.Forms.CheckBox

        ' Again, because sender is of type System.Object, explicitly convert
        ' the argument to a check box using the CType function
        chkCurrent = CType(sender, System.Windows.Forms.CheckBox)

        ' If the check box is checked, increment the number of occupied seats
        ' and decrement the number of empty seats. If the check box is not checked,
        ' then do the reverse.
        Select Case chkCurrent.Checked
            Case True
                mintFull += 1
                mintEmpty -= 1
            Case False
                mintFull -= 1
                mintEmpty += 1
        End Select

        ' Display the results in the labels.
        lblFull.Text = mintFull.ToString()
        lblEmpty.Text = mintEmpty.ToString()
    End Sub


    ' Uncheck all of the check boxes by enumerating the Controls collection of the Panel.
    Private Sub mmuSeatsClear_Click(sender As System.Object, e As System.EventArgs) Handles mmuSeatsClear.Click

        Dim ctlCurrent As Control
        Dim chkCurrent As CheckBox

        ' The For Each loop enumerates the Controls collection for the 
        ' Panel rather than the form.
        For Each ctlCurrent In pnlSeats.Controls
            ' Check that the type of the control instance is a CheckBox. 
            ' Labels are also contained by the Panel. If the control instance
            ' is a CheckBox, then remove the check mark by setting the Checked property
            ' to False.
            If TypeOf (ctlCurrent) Is System.Windows.Forms.CheckBox Then
                chkCurrent = CType(ctlCurrent, System.Windows.Forms.CheckBox)
                chkCurrent.Checked = False
            End If
        Next
        lblFull.Text = ""
        lblEmpty.Text = ""
    End Sub

    Private Sub mmuFileExit_Click(sender As System.Object, e As System.EventArgs) Handles mmuFileExit.Click
        Me.Close()
    End Sub


End Class
  • 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-19T03:53:40+00:00Added an answer on June 19, 2026 at 3:53 am

    Get the Char representation of the ascii value :

    Private Sub CreateSeatLabel(ByVal pintSeatCurrent As Integer)
        lblSeat(pintSeatCurrent) = New Label()
        lblSeat(pintSeatCurrent).Visible = True
        lblSeat(pintSeatCurrent).Text = Chr(pintSeatCurrent + 65)
        Me.pnlSeats.Controls.Add(lblSeat(pintSeatCurrent))
    End Sub
    

    65 is the value representing A character in ASCII Chart. Everytime the index increases by 1 you will get the next alphabetic character.

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

Sidebar

Related Questions

I have a flash movie that dynamically generates urls based on some params. Snip:
I have a movie clip that consists of a button and two labels (both
Im having some trouble getting the syntax right. I have a movie clip that
I have a flash movie that runs fine in FF, Opera, Safari but not
I have a list with category names , e.g. cats = [tv, movie, theater]
I have a movie file that does work. I added a tableview controller inside
i have 8 movie Clips that i stored in an array. i put the
I have movie database that has these tables: new_movies, ratings, critic_ratings, colors I'm trying
I have a movie which is embedded in my flash timeline so that I
I have a Movie model and a search page that has a movie genres

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.