Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27192

How to obtain the name of the dynamically created label your clicking on

$
0
0
Hello

I have labels dynamically created for which i have this code to run when one is double clicked

Code:

Private Sub label_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs)
       
    For Each Labelname As Label In Me.Controls.OfType(Of Label)().ToArray
            If Labelname.Name.Substring(0, 3) = ID Then
                If Labelname.BackColor = Color.Yellow Then
                    openbooking = True
                    Dim f2 As BookingForm
                    f2 = New BookingForm
                    f2.Visible = True
                    openbooking = True

                Else

                    If MessageBox.Show("Mark as collected?", " ", _
                    MessageBoxButtons.OKCancel, MessageBoxIcon.Question) Then
                        Labelname.BackColor = Color.Yellow

                    Else
                    End If
                End If

            End If
        Next


    End Sub

End Class

I need to set the variable "ID" to the name of the dynamically created label that is clicked on so that it changes its color and the name is then passed to the next form but cant figure how i get it!

Viewing all articles
Browse latest Browse all 27192

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>