Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

[TuT] ProgressBar we własnym designie


Xyli

Rekomendowane odpowiedzi

Opublikowano

Witam. Jest to mój pierwszy poradnik w dziale Visual Basic, więc proszę o wyrozumiałość.

 

Wytłumaczę, jak zrobić ProgressBara we własnym designie. :)

 

wasnyprogressbar.jpg

 

 

Poradnik:

 

 

Tworzymy nowy projekt w visualu.

Wybieramy z paska na górze ekranu Project, a potem Add User Control...

screenshot001qyf.jpg

 

W name wpisujemy MyProgressBar.vb i zatwierdzamy przyciskiem Add.

screenshot003bz.jpg

 

Teraz będziemy potrzebować dwóch plików (najlepiej w rozszerzeniu .png) do tła progressbara i do paska postępu. Ja robię paski 10x40 w gimpie. Jeżeli ktoś nie ma to w załączniku są wykonane przeze mnie z obrazka powyżej.

 

W Properties wybieramy BackgroundImage. Zaznaczamy Local resource: i klikamy Import.... Odszukujemy plik z tłem do progressbara. (W mojej paczce: tlo.png)

BackgroundImageLayout ustawiamy na Stretch

BorderStyle ustawiamy na FixedDialog

screenshot004bx.jpg

 

Nadajemy podłużny kształt formie naszego progressbara.

podunyksztalt.jpg

 

W Toolboxie wybieramy PictureBox i nanosimy na formę. Nadajemy PictureBox1 wysokość taką samą jaką ma forma progressbara.

 

Klikamy na PictureBox i w Properties wybieramy BackgroundImage. Zaznaczamy Local resource: i klikamy Import.... Odszukujemy plik z paskiem postępu progressbara. (W mojej paczce: postep.png)

BackgroundImageLayout ustawiamy na Stretch

BorderStyle ustawiamy na None.

Dock ustawiamy na Left.

Pierwszą wartość w Size ustawiamy na 0. (np. 0; wysokość_formy)

screenshot007hc.jpg

 

Klikamy F7, aby przejść do kodu formy i dopisujemy poniższy kod:

 

 Dim min As Integer = 0
Dim max As Integer = 100
Sub setvalue()
 PictureBox1.Width = (Me.Width / max) * min
End Sub
Property Value() As Integer
 Get
	 Return min
 End Get
 Set(ByVal value As Integer)
	 min = value
	 setvalue()
 End Set
End Property
Property maximum() As Integer
 Get
	 Return max
 End Get
 Set(ByVal value As Integer)
	 max = value
 End Set
End Property

 

 

http://wklej.to/0RNim

 

Przechodzimy do formy naszego progressbara i z Properties zmieniamy na Events (taki piorun).

screenshot008lo.jpg

 

Wyszukujemy Resize i podajemy wartość MyProgressBar_Resize.

przechwytywaniexh.jpg

 

Dopisujemy

 Private Sub MyProgressBar_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize
 setvalue()
End Sub

 

Mój kod formy progressbara:

http://wklej.to/WPCBx

 

Przechodzimy do naszej głównej formy i z paska na górze programu wybieramy Build i pierwszą opcję.

 

W Toolboxie mamy teraz naszego progressbara o nazwie MyProgressBar i posługujemy się nim tak samo jak normalnym.

przechwyt1ywanie.jpg

 

 

 

Proszę o komentarze.

Zakaz kopiowania i udostępniania bez wiedzy autora.

 

Pozdrawiam, Xyli

:)

pasek_postepu_xyli.rar

Napisz do mnie, jeżeli potrzebujesz patcher'a.

  • 1 miesiąc temu...
Opublikowano

Przed "i" nie stawiamy ","

 

@Temat

Bardzo fajne, łapiesz lajka

spam

 

@Top

 

Fajnie, ale to pokazałeś jak wgrać swój pasek postępu do swojego, a nie jak zrobić swój.

//Podoba mi sie taki progressbar :3

Opublikowano

spam

 

@Top

 

Fajnie, ale to pokazałeś jak wgrać swój pasek postępu do swojego, a nie jak zrobić swój.

//Podoba mi sie taki progressbar :3

 

 

Można się domyślić, że wystarczy edytować pliki, które umieściłem lub na takiej zasadzie to robić :D

Napisz do mnie, jeżeli potrzebujesz patcher'a.

  • 3 miesiące temu...
Opublikowano

czemu nie dziala integer

my code:

 

Public Class MyProgressBar
    Dim min As Integer = 0
    Dim max As Integer = 100
    Sub setvalue()
        PictureBox1.Width = (Me.Width / max) * min
    End Sub
    Property Value() As Integer
        Get
            Return min
        End Get
        Set(ByVal value As Integer)
            min = value
            setvalue()
        End Set
    End Property
    Property maximum() As Integer
        Get
            Return max
        End Get
        Set(ByVal value As Integer)
            max = value
        End Set
    End Property
 
    Private Sub MyProgressBar_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize
        setvalue()
    End Sub
 
    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
 
    End Sub
End Class
Opublikowano

 

czemu nie dziala integer

my code:

Public Class MyProgressBar
    Dim min As Integer = 0
    Dim max As Integer = 100
    Sub setvalue()
        PictureBox1.Width = (Me.Width / max) * min
    End Sub
    Property Value() As Integer
        Get
            Return min
        End Get
        Set(ByVal value As Integer)
            min = value
            setvalue()
        End Set
    End Property
    Property maximum() As Integer
        Get
            Return max
        End Get
        Set(ByVal value As Integer)
            max = value
        End Set
    End Property
 
    Private Sub MyProgressBar_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize
        setvalue()
    End Sub
 
    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
 
    End Sub
End Class
Jak może nie działać typ liczbowy.
Opublikowano

Jak może nie działać typ liczbowy.

niewiem wpisuje

 

MyProgressBar.integer(4)

i jest podkreslone na czerwono

Opublikowano

 

niewiem wpisuje

MyProgressBar.integer(4)

i jest podkreslone na czerwono

Daj kod tej funkcji.

Opublikowano

   
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        MyProgressBar1.Increment(4)
        If MyProgressBar1.Value = "100" Then
            Me.Hide()
            Timer1.Stop()
            Injectore.Show()
            MessageBox.Show("to successfully charge", "Completed")
        End If

a kod myprogressbar

 

 
Public Class MyProgressBar
    Dim min As Integer = 0
    Dim max As Integer = 100
    Sub setvalue()
        PictureBox1.Width = (Me.Width / max) * min
    End Sub
    Property Value() As Integer
        Get
            Return min
        End Get
        Set(ByVal value As Integer)
            min = value
            setvalue()
        End Set
    End Property
    Property maximum() As Integer
        Get
            Return max
        End Get
        Set(ByVal value As Integer)
            max = value
        End Set
    End Property
 
    Private Sub MyProgressBar_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize
        setvalue()
    End Sub
 
    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
 
    End Sub
End Class

 

Daj kod tej funkcji.

 

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        MyProgressBar1.Increment(4)
        If MyProgressBar1.Value = "100" Then
            Me.Hide()
            Timer1.Stop()
            Injectore.Show()
            MessageBox.Show("to successfully charge", "Completed")
        End If

a kod myprogressbar

 

Public Class MyProgressBar
    Dim min As Integer = 0
    Dim max As Integer = 100
    Sub setvalue()
        PictureBox1.Width = (Me.Width / max) * min
    End Sub
    Property Value() As Integer
        Get
            Return min
        End Get
        Set(ByVal value As Integer)
            min = value
            setvalue()
        End Set
    End Property
    Property maximum() As Integer
        Get
            Return max
        End Get
        Set(ByVal value As Integer)
            max = value
        End Set
    End Property
 
    Private Sub MyProgressBar_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize
        setvalue()
    End Sub
 
    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
 
    End Sub
End Class
Opublikowano

 

 


   
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        MyProgressBar1.Increment(4)
        If MyProgressBar1.Value = "100" Then
            Me.Hide()
            Timer1.Stop()
            Injectore.Show()
            MessageBox.Show("to successfully charge", "Completed")
        End If
a kod myprogressbar


 
Public Class MyProgressBar
    Dim min As Integer = 0
    Dim max As Integer = 100
    Sub setvalue()
        PictureBox1.Width = (Me.Width / max) * min
    End Sub
    Property Value() As Integer
        Get
            Return min
        End Get
        Set(ByVal value As Integer)
            min = value
            setvalue()
        End Set
    End Property
    Property maximum() As Integer
        Get
            Return max
        End Get
        Set(ByVal value As Integer)
            max = value
        End Set
    End Property
 
    Private Sub MyProgressBar_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize
        setvalue()
    End Sub
 
    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
 
    End Sub
End Class
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        MyProgressBar1.Increment(4)
        If MyProgressBar1.Value = "100" Then
            Me.Hide()
            Timer1.Stop()
            Injectore.Show()
            MessageBox.Show("to successfully charge", "Completed")
        End If
a kod myprogressbar


Public Class MyProgressBar
    Dim min As Integer = 0
    Dim max As Integer = 100
    Sub setvalue()
        PictureBox1.Width = (Me.Width / max) * min
    End Sub
    Property Value() As Integer
        Get
            Return min
        End Get
        Set(ByVal value As Integer)
            min = value
            setvalue()
        End Set
    End Property
    Property maximum() As Integer
        Get
            Return max
        End Get
        Set(ByVal value As Integer)
            max = value
        End Set
    End Property
 
    Private Sub MyProgressBar_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize
        setvalue()
    End Sub
 
    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
 
    End Sub
End Class

 

 

No i gdzie w myprogressbar jest funkcja integer?
Opublikowano

No i gdzie w myprogressbar jest funkcja integer?

a jak ją dodac

Xyli napisal : Przechodzimy do naszej głównej formy i z paska na górze programu wybieramy Build i pierwszą opcję.

 

W Toolboxie mamy teraz naszego progressbara o nazwie MyProgressBar i posługujemy się nim tak samo jak normalnym.

  • 4 tygodnie później...
Opublikowano

Przed "i" nie stawiamy ","

 

@Temat

Bardzo fajne, łapiesz lajka

 

Bardzo fajne :D Łapajta lajka =D

 

@quote

 

mi Pani na dyktandzie w szkole poprawiała, że przed "i" ma być "," :D

694101439111178842252.png

  • 1 miesiąc temu...
Opublikowano

Bardzo fajne :D Łapajta lajka =D

 

@quote

 

mi Pani na dyktandzie w szkole poprawiała, że przed "i" ma być "," :D

Może kazała ci pozstawić "," bo było to już drugie "i" czy trzecie. w tym zdaniu. Tylko przed pierwszym "i" nie stawiamy przecinka, przy kolejnych stawiamy.

@topic

Fajne, przyda się! Łap lajka !

Licze na Like !

 

Masz jakieś pytanie? Napisz mi na PW.

 

  • 2 tygodnie później...
Opublikowano

Przy używaniu tego progressbara program nie obsługuje funkcji Increment

 

  Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

If Loading11.Value = 1 Then

        ElseIf Loading11.Value = 60 Then


        ElseIf Loading11.Value = 99 Then

        End If
        If Loading11.Value = 100 Then
            Timer1.Stop()
            Label8.Visible = True
            Label7.Visible = False
            ComboBox4.Enabled = True
            Button3.Enabled = True
        End If
End Sub

Błąd brzmi - 'Increment' is not a member of 'Program.Loading1'.

 

U mnie progressbar nazywa się Loading1 a druga jedynka to numer użytego progressbara dlatego nazwa funkcji to Loading11

  • 10 miesięcy temu...
Opublikowano

Pomoze mi ktos ruszyc tego progress bara??

 

 

 

Sory za brak ogonkow ale jestem na telefonie.

http://pastebin.com/8eachZuW musisz miec progressbara i timera!

jeśli chodzi o kod do odpalenia tego to będzie

pod buttonem jakimś dajesz

timer1.start 

myśle że to jest timer 1 wiec możesz to zmienić zawsze

  • 8 miesięcy temu...
Opublikowano

Sub setvalue()
        PictureBox1.Width = (Me.Width / max) * min
    End Sub

    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click

    End Sub

 

Cały czas mi podkreśla i nw co mam zrobić.

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...