Download Aktiv, Textfarbe ändern sich

  • VB.NET
  • .NET (FX) 4.5–4.8

Es gibt 1 Antwort in diesem Thema. Der letzte Beitrag () ist von ThuCommix.

    Download Aktiv, Textfarbe ändern sich

    Hallo,

    ich habe ein Problem und zwar:
    wenn ich mein programm starte und der Download aktiv wird, dann ändert die form die text farbe wieder auf standart "schwarz".
    Eingestellt ist Weiß.

    kennt jemand den Fehler ?


    Spoiler anzeigen

    VB.NET-Quellcode

    1. Option Strict On
    2. Imports System.Net
    3. Imports System.Text
    4. Public Class Form1
    5. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    6. Using web = New WebClient() With {.Proxy = Nothing, .Encoding = Encoding.Default}
    7. Label4.Text = web.DownloadString("http://")
    8. End Using
    9. Timer1.Start()
    10. End Sub
    11. Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
    12. Dim client As WebClient = New WebClient
    13. AddHandler client.DownloadProgressChanged, AddressOf client_ProgressChanged
    14. AddHandler client.DownloadFileCompleted, AddressOf client_DownloadCompleted
    15. SW = Stopwatch.StartNew
    16. client.DownloadFileAsync(New Uri("http://download.thinkbroadband.com/200MB.zip"), Environment.CurrentDirectory & "\200MB.zip")
    17. Me.Text = "Download in Progress"
    18. Me.Enabled = False
    19. Timer1.Stop()
    20. End Sub
    21. Dim sw As New Stopwatch
    22. Private Sub client_ProgressChanged(ByVal sender As Object, ByVal e As DownloadProgressChangedEventArgs)
    23. Dim downloaded As String = CType(e.BytesReceived / 1024, String)
    24. Dim mussdownloaden As String = CType(e.TotalBytesToReceive / 1024, String)
    25. ProgressBar1.Value = e.ProgressPercentage
    26. Label1.Text = String.Format("{0:0.00} MB von {1:0.00} MB", e.BytesReceived / 1024 / 1024, e.TotalBytesToReceive / 1024 / 1024)
    27. Label2.Text = e.ProgressPercentage & "%"
    28. End Sub
    29. Private Sub client_DownloadCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs)
    30. MessageBox.Show("Download Complete")
    31. Me.Text = "Start Download"
    32. Me.Enabled = True
    33. Me.ProgressBar1.Value = 0
    34. Me.Label1.Text = "0 von 0 Bytes"
    35. Me.Label2.Text = "0%"
    36. End Sub
    37. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    38. Me.Close()
    39. End Sub
    40. End Class