Label Text ändern

  • VB.NET

Es gibt 23 Antworten in diesem Thema. Der letzte Beitrag () ist von RodFromGermany.

    Label Text ändern

    Hallo,
    ich möchte das mein Label den text hat den man unter Einstellungen eingestellt hat, bloß es funktioniert nicht.

    Code:

    VB.NET-Quellcode

    1. Public Class M_Button_1
    2. Inherits Windows.Forms.Control
    3. Dim WithEvents Unten As New PictureBox
    4. Dim WithEvents Intext As New Label
    5. Public WithEvents Text2 As String
    6. Public Sub New()
    7. Me.Controls.Add(Intext)
    8. Intext.Text = Text2
    9. Intext.AutoSize = False
    10. Intext.TextAlign = ContentAlignment.MiddleCenter
    11. Intext.Dock = DockStyle.Fill
    12. Me.Size = New System.Drawing.Point(75, 35)
    13. Me.Controls.Add(Unten)
    14. Unten.BackColor = Color.DarkRed
    15. Unten.Dock = DockStyle.Bottom
    16. Unten.Size = New System.Drawing.Point(5, 4)
    17. Intext.Font = New System.Drawing.Font("Tahoma", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    18. End Sub
    19. Private Sub M_Button_1_MouseLeave(sender As Object, e As EventArgs) Handles Me.MouseLeave
    20. Unten.BackColor = Color.Transparent
    21. Intext.ForeColor = Color.Gray
    22. End Sub
    23. Private Sub M_Button_1_MouseMove(sender As Object, e As MouseEventArgs) Handles Me.MouseMove
    24. Unten.BackColor = Color.DarkRed
    25. Intext.ForeColor = Color.Black
    26. End Sub
    27. Private Sub Unten_MouseLeave(sender As Object, e As EventArgs) Handles Unten.MouseLeave
    28. Unten.BackColor = Color.Transparent
    29. Intext.ForeColor = Color.Gray
    30. End Sub
    31. Private Sub Unten_MouseMove(sender As Object, e As MouseEventArgs) Handles Unten.MouseMove
    32. Unten.BackColor = Color.DarkRed
    33. Intext.ForeColor = Color.Black
    34. End Sub
    35. Private Sub Intext_MouseLeave(sender As Object, e As EventArgs) Handles Intext.MouseLeave
    36. Unten.BackColor = Color.Transparent
    37. Intext.ForeColor = Color.Gray
    38. End Sub
    39. Private Sub Intext_MouseMove(sender As Object, e As MouseEventArgs) Handles Intext.MouseMove
    40. Unten.BackColor = Color.DarkRed
    41. Intext.ForeColor = Color.Black
    42. End Sub
    43. End Class

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „GirlOnFire“ ()

    ?!

    VB.NET-Quellcode

    1. Public Class M_Button_1
    2. Inherits Windows.Forms.Control
    3. Dim WithEvents Unten As New PictureBox
    4. Dim WithEvents Intext As New Label
    5. Public Sub New()
    6. Intext.Text = Me.Text
    7. Me.Controls.Add(Intext)
    8. Intext.AutoSize = False
    9. Intext.TextAlign = ContentAlignment.MiddleCenter
    10. Intext.Dock = DockStyle.Fill
    11. Me.Size = New System.Drawing.Point(75, 35)
    12. Me.Controls.Add(Unten)
    13. Unten.Dock = DockStyle.Bottom
    14. Unten.Size = New System.Drawing.Point(5, 4)
    15. Intext.Font = New System.Drawing.Font("Tahoma", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    16. End Sub
    17. Private Sub M_Button_1_MouseLeave(sender As Object, e As EventArgs) Handles Me.MouseLeave
    18. Unten.BackColor = Color.Transparent
    19. Intext.ForeColor = Color.Gray
    20. End Sub
    21. Private Sub M_Button_1_MouseMove(sender As Object, e As MouseEventArgs) Handles Me.MouseMove
    22. Unten.BackColor = Color.DarkRed
    23. Intext.ForeColor = Color.Black
    24. End Sub
    25. Private Sub Unten_MouseLeave(sender As Object, e As EventArgs) Handles Unten.MouseLeave
    26. Unten.BackColor = Color.Transparent
    27. Intext.ForeColor = Color.Gray
    28. End Sub
    29. Private Sub Unten_MouseMove(sender As Object, e As MouseEventArgs) Handles Unten.MouseMove
    30. Unten.BackColor = Color.DarkRed
    31. Intext.ForeColor = Color.Black
    32. End Sub
    33. Private Sub Intext_MouseLeave(sender As Object, e As EventArgs) Handles Intext.MouseLeave
    34. Unten.BackColor = Color.Transparent
    35. Intext.ForeColor = Color.Gray
    36. End Sub
    37. Private Sub Intext_MouseMove(sender As Object, e As MouseEventArgs) Handles Intext.MouseMove
    38. Unten.BackColor = Color.DarkRed
    39. Intext.ForeColor = Color.Black
    40. End Sub
    41. End Class
    Also,

    VB.NET-Quellcode

    1. Dim WithEvents Intext As New Label

    soll denn text in den Eigenschaften von dem Control haben.
    Aber es ändert sich nicht zu den Text denn ich eingegeben habe.
    Bilder
    • Bild.png

      4,06 kB, 342×229, 116 mal angesehen