ahstax
Goto Top

Vb.net progressbar als kurzer Streifen

Hallo,

ist es möglich, die Progressbar in vb.net so anzusteuern, dass die Fortschrittsanzeige nur ein im Vergleich zum gesamt möglichen Balken kurzer Streifen ist, also etwa so wie bei K.I.T.T. als Lauflicht? Wenn ja, wie?

Neugierige Grüße,
Andreas

Content-Key: 361457

Url: https://administrator.de/contentid/361457

Printed on: April 19, 2024 at 03:04 o'clock

Mitglied: 135185
135185 Jan 17, 2018 updated at 16:13:21 (UTC)
Goto Top
Also wenn dir der Style "Marquee" der Progressbar nicht zusagt dann wirst du dir ein eigenes Steuerelement erstellen müssen, das sollte ja nicht weiter schwierig sein per GDI.
Member: emeriks
emeriks Jan 17, 2018 updated at 16:16:00 (UTC)
Goto Top
Hi,
Jain.
Es gibt den "Marquee"-Style.

Siehe Eigenschaften "Style" und "MarqueeAnimationSpeed".
Damit dann experimentieren.
Inwiefern Du das rückwärts laufen lassen kannst, weiß ich nicht. Musst Du testen.

E.
Member: ahstax
ahstax Jan 18, 2018 at 10:56:48 (UTC)
Goto Top
Danke für die Antworten! Ich habe mit der ProgressBar etwas rumexperimentiert und irgendwie... nun ja...
ich hab es jetzt mit Panels gelöst...:

   Public intFaktor As Integer = 20
   Public intAktuellesPanel As Integer = 1
   Public bolLeftToRight As Boolean = True

   Public Sub CreateBar(ByVal bolRemove As Boolean, ByRef bolCreate As Boolean)

        If bolRemove = True Then
            For i = 1 To intFaktor
                Dim pnlAkt As Panel = CType(Me.Controls("pnlPart" & i), Panel)  
                Me.Controls.Remove(pnlAkt)
            Next
        End If

        If bolCreate = True Then
            Dim intSizepnlPartX As Integer = CInt((Me.Size.Width - 40) / intFaktor)
            Dim intSizepnlPartY As Integer = 23
            Dim intLocationpnlPartX As Integer = 10
            Dim intLocationpnlPartY As Integer = (Me.Size.Height / 2) - intSizepnlPartY

            For i = 1 To intFaktor
                Dim pnlPart As New Panel()
                With pnlPart
                    .Name = "pnlPart" & i  
                    .Size = New Size(intSizepnlPartX, intSizepnlPartY)
                    .Location = New Point(intLocationpnlPartX, intLocationpnlPartY)
                    .BorderStyle = BorderStyle.None
                    .Visible = True
                End With
                Me.Controls.Add(pnlPart)
                intLocationpnlPartX = intLocationpnlPartX + intSizepnlPartX
            Next

            With Timer2
                .Interval = 50
                .Start()
            End With
        End If

    End Sub

    Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
        Timer2.Stop()

        Dim colColor As New Color
        colColor = Color.OliveDrab

        If intAktuellesPanel < intFaktor And bolLeftToRight = True Then
            intAktuellesPanel = intAktuellesPanel + 1
        ElseIf intAktuellesPanel < intFaktor And Not intAktuellesPanel = 1 And bolLeftToRight = False Then
            intAktuellesPanel = intAktuellesPanel - 1
        ElseIf intAktuellesPanel = intFaktor Then
            intAktuellesPanel = intAktuellesPanel - 1
            bolLeftToRight = False
        ElseIf intAktuellesPanel = 1 And bolLeftToRight = False Then
            intAktuellesPanel = intAktuellesPanel + 1
            bolLeftToRight = True
        ElseIf intAktuellesPanel = 1 And bolLeftToRight = True Then
            intAktuellesPanel = intAktuellesPanel + 1
        End If

        For i = 1 To intFaktor
            If intAktuellesPanel = i Then
                Dim pnlAkt As Panel = CType(Me.Controls("pnlPart" & i), Panel)  
                pnlAkt.BackColor = Color.FromArgb(100, colColor)

            ElseIf intAktuellesPanel - 1 = i And bolLeftToRight = True Then
                Dim pnlAkt As Panel = CType(Me.Controls("pnlPart" & i), Panel)  
                pnlAkt.BackColor = Color.FromArgb(100, colColor)
            ElseIf intAktuellesPanel - 2 = i And bolLeftToRight = True Then
                Dim pnlAkt As Panel = CType(Me.Controls("pnlPart" & i), Panel)  
                pnlAkt.BackColor = Color.FromArgb(80, colColor)
            ElseIf intAktuellesPanel - 3 = i And bolLeftToRight = True Then
                Dim pnlAkt As Panel = CType(Me.Controls("pnlPart" & i), Panel)  
                pnlAkt.BackColor = Color.FromArgb(50, colColor)
            ElseIf intAktuellesPanel - 4 = i And bolLeftToRight = True Then
                Dim pnlAkt As Panel = CType(Me.Controls("pnlPart" & i), Panel)  
                pnlAkt.BackColor = Color.FromArgb(20, colColor)
            ElseIf intAktuellesPanel - 5 = i And bolLeftToRight = True Then
                Dim pnlAkt As Panel = CType(Me.Controls("pnlPart" & i), Panel)  
                pnlAkt.BackColor = Color.FromArgb(20, colColor)
            ElseIf intAktuellesPanel - 6 = i And bolLeftToRight = True Then
                Dim pnlAkt As Panel = CType(Me.Controls("pnlPart" & i), Panel)  
                pnlAkt.BackColor = Color.FromArgb(10, colColor)

            ElseIf intAktuellesPanel + 1 = i And bolLeftToRight = False Then
                Dim pnlAkt As Panel = CType(Me.Controls("pnlPart" & i), Panel)  
                pnlAkt.BackColor = Color.FromArgb(100, colColor)
            ElseIf intAktuellesPanel + 2 = i And bolLeftToRight = False Then
                Dim pnlAkt As Panel = CType(Me.Controls("pnlPart" & i), Panel)  
                pnlAkt.BackColor = Color.FromArgb(80, colColor)
            ElseIf intAktuellesPanel + 3 = i And bolLeftToRight = False Then
                Dim pnlAkt As Panel = CType(Me.Controls("pnlPart" & i), Panel)  
                pnlAkt.BackColor = Color.FromArgb(50, colColor)
            ElseIf intAktuellesPanel + 4 = i And bolLeftToRight = False Then
                Dim pnlAkt As Panel = CType(Me.Controls("pnlPart" & i), Panel)  
                pnlAkt.BackColor = Color.FromArgb(20, colColor)
            ElseIf intAktuellesPanel + 5 = i And bolLeftToRight = False Then
                Dim pnlAkt As Panel = CType(Me.Controls("pnlPart" & i), Panel)  
                pnlAkt.BackColor = Color.FromArgb(20, colColor)
            ElseIf intAktuellesPanel + 6 = i And bolLeftToRight = False Then
                Dim pnlAkt As Panel = CType(Me.Controls("pnlPart" & i), Panel)  
                pnlAkt.BackColor = Color.FromArgb(10, colColor)
            Else
                Dim pnlAkt As Panel = CType(Me.Controls("pnlPart" & i), Panel)  
                pnlAkt.BackColor = Color.Transparent
            End If
        Next

        With Timer2
            .Interval = 50
            .Start()
        End With
    End Sub
Member: colinardo
Solution colinardo Jan 20, 2018 updated at 14:23:23 (UTC)
Goto Top
Servus Andreas,
auch wenn du es schon gelöst hast hier mal noch für alle anderen die es brauchen können das geschilderte als fertiges rudimentäres .NET Control zum Einbinden in die Toolbox von VS, kompiliert gegen .NET 4.0 mit anpassbaren Eigenschaften.
CustomProgressbarControl_NET40_361457.dll

Anpassbare Eigenschaften:

screenshot

Und den Methoden Start() und Stop() zum Steuern der Animation.

Grüße Uwe