Hi everybody, this is my first post!
I'm designing a booking system that creates labels in a panel which, when clicked on, will turn red to indicate a booking. I'm getting a crash, and I'm unsure why. It often makes Visual Studio (2010) crash, too! Please help! What's going wrong? ![:(]()
The crash occurs on the final line. Everything up to there works. After this, I have:
Many thanks for your help!


Private Sub Matrix_Display_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Dim i, j As Integer Dim Myfont As New Font("Ariel", 7) Dim PCFile As String = CurDir() & "\PCFile.dat" Me.Text = "PC Room Layout" For i = 0 To 15 For j = 0 To 6 Display(i, j) = New Label Display(i, j).Name = i & "," & j pnlDisplay.Controls.Add(Display(i, j)) Display(i, j).Width = 45 Display(i, j).Height = 45 Display(i, j).FlatStyle = BorderStyle.Fixed3D Display(i, j).Left = i * Display(0, 0).Left + 45 Display(i, j).Top = j * Display(0, 0).Top + 45 Display(i, j).BackColor = Color.MediumSeaGreen Display(i, j).ForeColor = Color.Yellow Display(i, j).BorderStyle = BorderStyle.Fixed3D Display(i, j).TextAlign = ContentAlignment.MiddleCenter Display(i, j).Font = Myfont Display(i, j).Text = "Not" & vbNewLine & "Booked" Next Next For i = 1 To 15 For j = 1 To 5 Step 2 Display(i, j).Hide() Next Next AddHandler Display(i, j).Click, AddressOf Clicked
The crash occurs on the final line. Everything up to there works. After this, I have:
Private Sub Clicked(ByVal sender As Object, ByVal e As EventArgs) Me.BackColor = Color.Red End Sub
Many thanks for your help!
