Autor Tema: Label Virtual  (Leído 1509 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Angel27

  • Bit
  • Mensajes: 5
  • Reputación: +0/-0
  • Ahorra Agua... Beba Cerveza
    • Ver Perfil
Label Virtual
« en: Noviembre 22, 2019, 08:16:54 pm »
Saludos Estoy generando un label virtualmente, conjuntamente con un control picbox relamente los labels vienen desde una table osea pueden ser mas de uno en todo caso, esto es para meterlo en un control FlowLayoutPanel todo bien, pero cuando quiero cambiar la propiedad de este label al seleccionar el evento click del picbox no logro dar con el label que le corresponde a ese picbox. Osea al pasarle el sender del objeto encuentra que no es tipo label sino picbox y no logro cargarle las propiedades al label de su clase. Aunque le diga que es label ni asi ni nada y no encuentro nada en la red aun con relacion a esto.

Le agrego algo del code en cuetion para ver si me dan ualgo de Luz THKS...

Public Sub Crea_Picture()
      For L As Integer = 0 To UBound(maCtrl, 2)

            Dim nPic As PictureBox = New PictureBox
            nPic.Name = "pic" + L.ToString("000")

            If Not IsDBNull(maCtrl(4, L)) Then

                Dim f As MemoryStream
                f = New MemoryStream(CType(maCtrl(4, L), Byte()))

                nPic.Image = Image.FromStream(f)
            Else

                nPic.Image = Nothing

            End If

            nPic.SizeMode = PictureBoxSizeMode.StretchImage

            Dim nbtn As Label = New Label
            nbtn.Name = "lbl" + L.ToString("000")
            nbtn.Text = maCtrl(1, L)
            nbtn.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
            nbtn.ForeColor = System.Drawing.Color.White
            nbtn.Location = New System.Drawing.Point(15, 141)
            nbtn.Size = New System.Drawing.Size(172, 22)
            nbtn.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
            '

            Dim LPanel1 As TableLayoutPanel = New TableLayoutPanel
            LPanel1.ColumnCount = 1
            LPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100.0!))

            'Me.TableLayoutPanel1.Location = New System.Drawing.Point(3, 3)
            LPanel1.Name = "TLPanel1"
            LPanel1.RowCount = 2
            LPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 141.0!))
            LPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100.0!))     
            LPanel1.Size = New System.Drawing.Size(150, 170)
            'LPanel1.TabIndex = 0

            LPanel1.Controls.Add(nPic, 0, 0)
            LPanel1.Controls.Add(nbtn, 0, 1)
            nPic.Size = New System.Drawing.Size(145, 145)
            nPic.Location = New System.Drawing.Point(3, 3)
            nbtn.Dock = DockStyle.Fill
            Me.FLPanel1.Controls.Add(LPanel1)

            AddHandler nPic.Click, AddressOf mytxtbtn_Click

 End Sub

Private Sub mytxtbtn_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim paso As Boolean = False
        Dim LPanel1 As TableLayoutPanel = New TableLayoutPanel
        'Dim LblActivo As Label

        '************* llamar rutina agregar a la Lista ************
        Dim npos As Integer = maCtrl(0, Microsoft.VisualBasic.Right(CType(sender, PictureBox).Name, 3))
        Dim NameIngrediente As String = maCtrl(1, Microsoft.VisualBasic.Right(CType(sender, PictureBox).Name, 3))
        Dim ItemCodeIngrediente As String = maCtrl(1, Microsoft.VisualBasic.Right(CType(sender, PictureBox).Name, 3))

        LblActivo.Name = "lbl" + Microsoft.VisualBasic.Right(CType(sender, PictureBox).Name, 3)   'No sale esta vayna
       Type(sender, Label).ForeColor = System.Drawing.Color.White   'Tampoco Asip


       'MsgBox("npos: " + CType(sender, PictureBox).BorderStyle)
        If CType(sender, PictureBox).BorderStyle = BorderStyle.None Then
            AgregarYN = 1
            CType(sender, PictureBox).BorderStyle = BorderStyle.Fixed3D
        ElseIf CType(sender, PictureBox).BorderStyle = BorderStyle.Fixed3D Then
            AgregarYN = 0
            CType(sender, PictureBox).BorderStyle = BorderStyle.None
        End If
        Call AgregarIngredienteLista(AgregarYN, NameIngrediente, ItemCodeIngrediente)

End Sub


NO se si me doy a entender porque casi ni yo mismo me entiendo XD.